Title: Custom Query Shortcode
Author: Peter Hebert
Published: <strong>ستمبر 22, 2015</strong>
Last modified: اگست 22, 2025

---

پلگ انز تلاش کریں

یہ پلگ ان **ورڈپریس کے تازہ ترین 3 ریلیزوں کے ساتھ ٹیسٹ نہیں کیا گیا ہے**۔ اب یہ
برقرار نہیں رکھا جا سکتا یا معاونت نہیں کی جا سکتی اور اس کو ورڈپریس کے تازہ ترین
ورژنز کے ساتھ استعمال کیے جانے پر مطابقت کے مسائل ہو سکتے ہیں۔

![](https://s.w.org/plugins/geopattern-icon/custom-query-shortcode.svg)

# Custom Query Shortcode

 منجانب [Peter Hebert](https://profiles.wordpress.org/peterhebert/)

[ڈاؤن لوڈ کریں](https://downloads.wordpress.org/plugin/custom-query-shortcode.0.5.0.zip)

 * [تفصیلات](https://ur.wordpress.org/plugins/custom-query-shortcode/#description)
 * [جائزے](https://ur.wordpress.org/plugins/custom-query-shortcode/#reviews)
 *  [انسٹالیشن](https://ur.wordpress.org/plugins/custom-query-shortcode/#installation)
 * [ڈیولپمنٹ](https://ur.wordpress.org/plugins/custom-query-shortcode/#developers)

 [معاونت](https://wordpress.org/support/plugin/custom-query-shortcode/)

## تفصیل

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](https://codex.wordpress.org/Class_Reference/WP_Query)
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](https://codex.wordpress.org/Function_Reference/add_image_size#Reserved_Image_Size_Names)
   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})](https://ur.wordpress.org/plugins/custom-query-shortcode/{URL}?output_format=md)󠁿

[/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](http://getbootstrap.com/) CSS framework. The generated markup is
compliant with the 5.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](https://wordpress.org/extend/plugins/bootstrap/)).

[Tabs](http://getbootstrap.com/javascript/#tabs)

This will show the latest 3 posts in a tabbed widget.
 [query posts_per_page=”3″
lens=”tabs”]

[Accordion](http://getbootstrap.com/javascript/#tabs)

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](http://getbootstrap.com/javascript/#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

Starting with version 0.4, you can use Twig templates for your output. Support for
Twig is provided by the [Timber](https://github.com/timber/timber) library.

This requires that Timber 2.x be installed as a [Composer dependency](https://timber.github.io/docs/v2/installation/installation/).

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](https://timber.github.io/docs/v2/guides/template-locations/#changing-the-default-folder-for-twig-files)
in Timber.

Examples:

    ```
    [query twig_template="template-name.twig"]
    [query twig_template="folder/template-name.twig"]
    ```

## اسکرین شاٹس

[⌊Example of shortcode syntax⌉⌊Example of shortcode syntax⌉[

Example of shortcode syntax

## انسٹالیشن

 1. Upload the whole plugin directory to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Now use `[query]` shortcode anywhere you want.
 4. Enjoy!

## عمومی سوالات

no questions have been asked yet.

## جائزے

![](https://secure.gravatar.com/avatar/bb5acc7c7e238d6c7b86dd8887a2d3ec53d6448b96ebb838d5b6ec6f86587c8d?
s=60&d=retro&r=g)

### 󠀁[Simple and nice](https://wordpress.org/support/topic/simple-and-nice-50/)󠁿

 [ibes](https://profiles.wordpress.org/ib4s/) ستمبر 15, 2017

Nice Plugin to have simple and useful shortcodes to present content. Super helpful
to be able to use custom templates. I would like to have a way to give data to the
templates. For example a class that should be added for this one.

 [ تمام 1 جائزے پڑھیں ](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/)

## شراکت دار اور ڈیویلپرز

“Custom Query Shortcode” اوپن سورس سافٹ ویئر ہے۔ مندرجہ ذیل لوگوں نے اس پلگ ان میں
حصہ لیا:

شراکت دار

 *   [ Peter Hebert ](https://profiles.wordpress.org/peterhebert/)
 *   [ shazdeh ](https://profiles.wordpress.org/shazdeh/)

[“Custom Query Shortcode” کا اپنی زبان میں ترجمہ کریں۔](https://translate.wordpress.org/projects/wp-plugins/custom-query-shortcode)

### ڈویلپمینٹ میں دلچسپی ہے؟

[کوڈ براؤز کریں](https://plugins.trac.wordpress.org/browser/custom-query-shortcode/)،
[ایس این وی ریپوزیٹری](https://plugins.svn.wordpress.org/custom-query-shortcode/)
کو چیک کریں یا [ڈویلپمینٹ لاگ](https://plugins.trac.wordpress.org/log/custom-query-shortcode/)
کو سبسکرائب کریں بذریعہ [آر ایس ایس](https://plugins.trac.wordpress.org/log/custom-query-shortcode/?limit=100&mode=stop_on_copy&format=rss)۔

## چینج لاگ

#### 0.5.0

 * Security release – fixes to address path traversal vulnerability as noted in 
   CVE-2025-8562.
 * Added localization template .pot

#### 0.4.0

 * Added Twig templating support via the Timber Library – note we do not include
   Timber with this plugin.

#### 0.3

 * Added a new directory to search for lenses within the current theme – ‘query-
   shortcode-templates’
 * Revamped readme.txt documentation

#### 0.2.5

 * Changed lens ‘ul’, removing post date. I also added lens ‘ul-title-date’, which
   is the equivalent of the previous ‘ul’ lens.

#### 0.2.4

 * Added lens ‘ul’, presenting an unordered list of query results with post date
   displayed.

#### 0.2.3

 * Added lens ‘article-excerpt-date’, which is the same as ‘article-excerpt’, except
   with the post date displayed.

#### 0.2.2

 * Added a filter to allow shortcodes within widget areas, which makes this plugin
   a lot more useful.

#### 0.2.1.1

 * Added a second directory to search for lenses within the current theme – ‘partials/
   custom-query-lenses’.

#### 0.2.1

 * Added posts_separator parameter.

#### 0.2

 * Added Lens functionality. Now you can build tabs, accordions, and carousels (
   and build custom ones) out of queried posts. Relies on Twitter Bootstrap framework.

## میٹا

 *  Version **0.5.0**
 *  Last updated **1 سال پہلے**
 *  Active installations **20+**
 *  WordPress version ** 3.3 یا اس سے جدید **
 *  Tested up to **6.8.11**
 *  Language
 * [English (US)](https://wordpress.org/plugins/custom-query-shortcode/)
 * Tags
 * [post](https://ur.wordpress.org/plugins/tags/post/)[query](https://ur.wordpress.org/plugins/tags/query/)
   [shortcode](https://ur.wordpress.org/plugins/tags/shortcode/)
 *  [اعلی درجے کا منظر](https://ur.wordpress.org/plugins/custom-query-shortcode/advanced/)

## درجہ بندیاں

 5 out of 5 stars.

 *  [  1 5-star review     ](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/custom-query-shortcode/reviews/)

## شراکت دار

 *   [ Peter Hebert ](https://profiles.wordpress.org/peterhebert/)
 *   [ shazdeh ](https://profiles.wordpress.org/shazdeh/)

## معاونت

کچھ کہنا ہے؟ مدد چاہیے؟

 [معاونتی فورم دیکھیں](https://wordpress.org/support/plugin/custom-query-shortcode/)