WordPress plugin intelligence profile

Custom Query Shortcode

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.

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 6.8
Current version0.5.0
WordPress coverageTested up to WordPress 6.8
Minimum stackWP 3.3 · PHP —
Directory statusactive
Last directory update22 Aug 20251y ago
Active installations20Adoption metric — not a quality score
WordPress.org rating5.0 / 5 from 1 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Custom Query Shortcode version 0.5.0 as active, updated 1y ago and tested up to WordPress 6.8.

Overview

About this plugin

This plugin gives you [query] shortcode which enables you to query and output any posts filtered by specific attributes.

Usage

You can use most parameters supported by WP_Query class to filter the posts; you can query for specific post types, categories, tags, authors, etc.

Other supported parameters

Aside from WP_Query parameters, the shortcode also supports the following additional parameters:

  • featured: to query for sticky posts which by default are excluded from the query.
  • thumbnail_size: to specify the size of the {THUMBNAIL} images. You can use built-in image sizes or custom ones you’ve defined.
  • content_limit: to limit the number of words of the {CONTENT} var; by default it’s “0” which means it outputs the whole content.
  • posts_separator: text to display between individual posts.
  • lens: custom output template – see description below.
  • twig_template: output template using Twig templating engine – requires the Timber library.

Formatting the output

You can define how you want to format the output inline within an opening [query] and closing [/query] tag.

Available keywords are: TITLE, CONTENT, AUTHOR, AUTHOR_URL, DATE, THUMBNAIL, CONTENT, COMMENT_COUNT.

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:

[query posts_per_page=”5″ cat=”3″]

{TITLE} ({COMMENT_COUNT})

[/query]

Grid display

With the “cols” parameter you can display the output in a grid.

[query posts_per_page=”3″ cols=”3″] {THUMBNAIL}

{TITLE}

{CONTENT} [/query]

will display the latest 3 posts in the defined template, in 3 columns.

The plugin will automatically divide the grid into rows based upon the ‘posts_per_page’ option, divided by the ‘cols’ option.

Lenses (output templates)

With the “lens” parameter you can customize the display of the query results using a template. Some basic lenses/templates are provided:

  • ul: unordered list of linked post titles.
  • ul-title-date: same as ‘ul’, but also displays the posted date.
  • article-excerpt: series of articles, with a header containing the linked post title, and the excerpt.
  • article-excerpt-date: same as ‘article-excerpt’, but also displays the posted date.
  • cards: displays the post thumb above the header with linked post title, followed by the excerpt.

Bootstrap lenses

Some pre-defined lenses/templates are provided which use JavaScript Components from the Bootstrap CSS framework. x version of Bootstrap.

This feature relies on Bootstrap library to be already loaded on the page, the plugin does not include it.

If you’re using a Bootstrap-based theme, this should work; otherwise you can use the Bootstrap plugin ).

Tabs

This will show the latest 3 posts in a tabbed widget.

[query posts_per_page=”3″ lens=”tabs”]

Accordion

This will create an accordion widget of all our posts from the “faq” post type.

[query posts_per_page=”0″ post_type=”faq” lens=”accordion”]

Carousel

This creates a carousel of latest five featured posts:

[query posts_per_page=”5″ featured=”true” lens=”carousel”]

Custom Lenses/templates

You can create your own custom templates and put them into one of these pre-defined folder names within your theme:

  • ‘query-shortcode-templates’
  • ‘partials/query-shortcode-lenses/’
  • ‘html/lenses/’

Or simply specify your own subfolder in the ‘lens’ parameter:

[query lens=”folder/template-name”]

Twig Template Support

4, you can use Twig templates for your output. Support for Twig is provided by the Timber library.

x be installed as a Composer dependency.

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 views folder in your active theme. You can change the default template location in Timber.

Examples:

twig"]

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • post
  • query
  • shortcode
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 6.8

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 6.8.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to6.8
Minimum requirementsWordPress 3.3 · PHP not listed
Update activity22 Aug 20251y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.