You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A powerful shortcode that enables you to query anything you want and display it however you like, on both pages and posts, and in widgets.
12
13
13
-
14
14
## Description
15
15
16
-
This plugin gives you a `[query]` shortcode which enables you to query and output any posts filtered by specific attributes.
17
-
16
+
This plugin gives you <code>[query]</code> shortcode which enables you to query and output any posts filtered by specific attributes.
18
17
19
18
### Usage
20
19
21
-
You can use all parameters supported by the [WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query) class to filter the posts; you can query for specific post types, categories, tags, authors, etc.
22
-
20
+
You can use most parameters supported by <ahref="http://codex.wordpress.org/Class_Reference/WP_Query">WP_Query class</a> to filter the posts; you can query for specific post types, categories, tags, authors, etc.
23
21
24
22
### Other supported parameters
25
23
26
-
Aside from [WP_Query parameters](https://codex.wordpress.org/Class_Reference/WP_Query#Parameters), the shortcode also supports the following additional parameters:
24
+
Aside from WP_Query parameters, the shortcode also supports the following additional parameters:
27
25
28
26
**featured*: to query for sticky posts which by default are excluded from the query.
29
27
**thumbnail_size*: to specify the size of the {THUMBNAIL} images. You can use <ahref="http://codex.wordpress.org/Function_Reference/add_image_size#Reserved_Image_Size_Names">built-in image sizes</a> or custom ones you've defined.
30
28
**content_limit*: to limit the number of words of the {CONTENT} var; by default it's "0" which means it outputs the whole content.
31
29
**posts_separator*: text to display between individual posts.
32
30
**lens*: custom output template - see description below.
33
-
**twig_template*: output template using [Twig](https://twig.sensiolabs.org/) templating engine - requires the [Timber](https://github.com/timber/timber) library.
34
-
31
+
**twig_template*: output template using Twig templating engine - requires the Timber library.
35
32
36
33
### Formatting the output
37
-
You can define how you want to format the output inline within an opening `[query]` and closing `[/query]` tag.
38
34
35
+
You can define how you want to format the output inline within an opening <code>[query]</code> and closing <code>[/query]</code> tag.
The following example will display the latest 5 posts from the category with the ID of 3, showing a post title and comment count, with a link to the post:
will display the latest 3 posts in the defined template, in 3 columns.
62
45
The plugin will automatically divide the grid into rows based upon the 'posts_per_page' option, divided by the 'cols' option.
63
46
64
47
### Lenses (output templates)
48
+
65
49
With the "lens" parameter you can customize the display of the query results using a template. Some basic lenses/templates are provided:
66
50
67
51
***ul**: unordered list of linked post titles.
@@ -70,111 +54,114 @@ With the "lens" parameter you can customize the display of the query results usi
70
54
***article-excerpt-date**: same as 'article-excerpt', but also displays the posted date.
71
55
***cards**: displays the post thumb above the header with linked post title, followed by the excerpt.
72
56
73
-
#### Bootstrap support
57
+
<h5>Bootstrap lenses</h5>
58
+
Some pre-defined lenses/templates are provided which use JavaScript Components from the <ahref="http://getbootstrap.com/">Bootstrap</a> CSS framework. The generated markup is compliant with the 5.x version of Bootstrap.
74
59
75
-
Some pre-defined lenses/templates are provided which use JavaScript Components from the [Bootstrap](http://getbootstrap.com/) CSS framework.
60
+
This feature relies on Bootstrap library to be already loaded on the page, the plugin does *not* include it.
76
61
77
-
This feature relies on the Bootstrap library to be already loaded on the page, the plugin does *not* include it.
78
-
79
-
If you're using a Bootstrap-based theme, this *should* work; otherwise you can use the [Bootstrap plugin](http://wordpress.org/extend/plugins/bootstrap/) for WordPress.
If you're using a Bootstrap-based theme, this *should* work; otherwise you can use the <ahref="http://wordpress.org/extend/plugins/bootstrap/">Bootstrap plugin</a>).
You can create your own custom templates and put them into one of these pre-defined folder names within your theme:
109
78
110
79
* 'query-shortcode-templates'
111
80
* 'partials/query-shortcode-lenses/'
112
81
* 'html/lenses/'
113
82
114
83
Or simply specify your own subfolder in the 'lens' parameter:
115
-
116
-
```
117
-
[query lens="folder/template-name"]
118
-
```
84
+
<code>[query lens="folder/template-name"]</code>
119
85
120
86
### Twig Template Support
121
-
Starting with version 0.4, you can use [Twig](https://twig.sensiolabs.org/) templates for your output. Support for Twig is provided by the [Timber](https://github.com/timber/timber) library.
122
87
123
-
This requires that Timber be [installed as a plugin](https://en-ca.wordpress.org/plugins/timber-library/) or [included in your theme](http://timber.github.io/timber/#getting-started).
88
+
Starting with version 0.4, you can use Twig templates for your output. Support for Twig is provided by the <ahref="https://github.com/timber/timber">Timber</a> library.
89
+
90
+
This requires that Timber 2.x be installed as a <ahref="https://timber.github.io/docs/v2/installation/installation/">Composer dependency</a>.
91
+
92
+
To use a Twig template for your query output, simply use the 'twig_template' parameter instead of the 'lens' parameter, and provide the path to your template. By default, Timber looks within the <code>views</code> folder in your active theme. You can <ahref="https://timber.github.io/docs/v2/guides/template-locations/#changing-the-default-folder-for-twig-files">change the default template location</a> in Timber.
124
93
125
-
To use a Twig template for your query output, simply use the 'twig_template' parameter instead of the 'lens' parameter, and provide the path to your template:
94
+
Examples:
126
95
127
-
```
96
+
<pre><code>
97
+
[query twig_template="template-name.twig"]
128
98
[query twig_template="folder/template-name.twig"]
129
-
```
99
+
</code></pre>
130
100
131
101
## Installation
132
102
133
103
1. Upload the whole plugin directory to the `/wp-content/plugins/` directory
134
104
2. Activate the plugin through the 'Plugins' menu in WordPress
135
-
3. Now use the `[query]` shortcode anywhere you want.
105
+
3. Now use <code>[query]</code> shortcode anywhere you want.
136
106
4. Enjoy!
137
107
138
108
109
+
139
110
## Frequently Asked Questions
140
111
141
112
no questions have been asked yet.
142
113
143
-
144
114
## Screenshots
145
115
146
116
### 1. Example of shortcode syntax
147
-

117
+
118
+
[missing image]
119
+
148
120
149
121
## Changelog
150
122
123
+
### 0.5.0
124
+
125
+
* Security release - fixes to address path traversal vulnerability as noted in CVE-2025-8562.
126
+
* Added localization template .pot
127
+
151
128
### 0.4.0
152
-
* Added Twig templating support via the Timber Library
129
+
130
+
* Added Twig templating support via the Timber Library - note we do not include Timber with this plugin.
153
131
154
132
### 0.3
133
+
155
134
* Added a new directory to search for lenses within the current theme - 'query-shortcode-templates'
156
135
* Revamped readme.txt documentation
157
136
158
137
### 0.2.5
138
+
159
139
* Changed lens 'ul', removing post date. I also added lens 'ul-title-date', which is the equivalent of the previous 'ul' lens.
160
140
161
141
### 0.2.4
142
+
162
143
* Added lens 'ul', presenting an unordered list of query results with post date displayed.
163
144
164
145
### 0.2.3
146
+
165
147
* Added lens 'article-excerpt-date', which is the same as 'article-excerpt', except with the post date displayed.
166
148
167
149
### 0.2.2
150
+
168
151
* Added a filter to allow shortcodes within widget areas, which makes this plugin a lot more useful.
169
152
170
153
### 0.2.1.1
154
+
171
155
* Added a second directory to search for lenses within the current theme - 'partials/custom-query-lenses'.
172
156
173
157
### 0.2.1
158
+
174
159
* Added posts_separator parameter.
175
160
176
161
### 0.2
162
+
177
163
* Added Lens functionality. Now you can build tabs, accordions, and carousels (and build custom ones) out of queried posts. Relies on Twitter Bootstrap framework.
178
164
179
165
## Upgrade Notice
166
+
180
167
Upgrades are handled just like any other WordPress plugin.
0 commit comments