Title: Query Shortcode
Author: shazdeh
Published: <strong>2013 年 1 月 15 日</strong>
Last modified: 2013 年 4 月 27 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

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

# Query Shortcode

 作者：[shazdeh](https://profiles.wordpress.org/shazdeh/)

[下载](https://downloads.wordpress.org/plugin/query-shortcode.zip)

 * [详情](https://cn.wordpress.org/plugins/query-shortcode/#description)
 * [评价](https://cn.wordpress.org/plugins/query-shortcode/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/query-shortcode/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/query-shortcode/#developers)

 [支持](https://wordpress.org/support/plugin/query-shortcode/)

## 描述

This plugin gives you `[query]` shortcode which enables you to output posts filtered
by specific attributes. You can format the output to your liking and even display
the results in a grid of customizable columns and rows.
 Also supports “lenses” 
which can turn your query results into Tabs, Accordion, or Carousel widgets. This
feature relies on Bootstrap library to be already loaded on the page, the plugin
does _not_ include it (for that you can use the [Bootstrap plugin](https://wordpress.org/extend/plugins/bootstrap/)).
You can create new lenses or override the built-in ones in your theme to customize
the output.

#### Usage

You can use all 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. You also have to define how you want to format the output:
 [query posts_per_page
=”5″ cat=”3″]

### 󠀁[{TITLE} ({COMMENT_COUNT})](https://cn.wordpress.org/plugins/query-shortcode/{URL}?output_format=md)󠁿

[/query]
 The above shortcode will display the title of the latest 5 posts from 
the category with the ID of 3. Available keywords are: TITLE, CONTENT, AUTHOR, AUTHOR_URL,
DATE, THUMBNAIL, CONTENT, COMMENT_COUNT and more to be added later.

#### Grid display

With the “cols” parameter you can display the output in a grid. So this:
 [query
posts_per_page=”3″ cols=”3″] {THUMBNAIL}

### {TITLE}

{CONTENT} [/query]
 will display the latest 3 posts in the defined template, in 
3 columns. If in the above snippet we set the posts_per_page option to 6, it will
display the latest 6 posts in two rows that each has 3 columns.

#### Lenses

With the “lens” parameter you can display the query results in a Tab, Accordion,
or Carousel widget. Example:
 [query posts_per_page=”0″ post_type=”faq” lens=”accordion”]
This will create an accordion widget of all our posts from the “faq” post type. 
This creates a carousel of latest five featured posts: [query posts_per_page=”5″
featured=”true” lens=”carousel”]

#### Other supported parameters

Aside from wp_query parameters, the shortcode also supports 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.

## 安装

 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!= 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.

## 评价

此插件暂无评价。

## 贡献者及开发者

「Query Shortcode」是开源软件。 以下人员对此插件做出了贡献。

贡献者

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

[帮助将「Query Shortcode」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/query-shortcode)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/query-shortcode/)，查看
[SVN仓库](https://plugins.svn.wordpress.org/query-shortcode/)，或通过[RSS](https://plugins.trac.wordpress.org/log/query-shortcode/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/query-shortcode/)。

## 额外信息

 *  版本 **0.2.1**
 *  最后更新：**13 年前**
 *  活跃安装数量 **30+**
 *  WordPress 版本 ** 3.3 或更高版本 **
 *  已测试的最高版本为 **3.6.1**
 *  语言
 * [English (US)](https://wordpress.org/plugins/query-shortcode/)
 * 标签
 * [post](https://cn.wordpress.org/plugins/tags/post/)[query](https://cn.wordpress.org/plugins/tags/query/)
   [shortcode](https://cn.wordpress.org/plugins/tags/shortcode/)
 *  [高级视图](https://cn.wordpress.org/plugins/query-shortcode/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  5 条 5 星评价     ](https://wordpress.org/support/plugin/query-shortcode/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/query-shortcode/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/query-shortcode/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/query-shortcode/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/query-shortcode/reviews/?filter=1)

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

[查看全部评论](https://wordpress.org/support/plugin/query-shortcode/reviews/)

## 贡献者

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

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/query-shortcode/)