Plugin Directory

Test out the new Plugin Directory and let us know what you think.
!This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WPQuery Shortcode

A lightweight plugin that wraps the functionality of WP_Query in an easy-to-use shortcode.

WPQuery Shortcode is a lightweight plugin that wraps the functionality of WP_Query in an easy-to-use shortcode.

Several filters are built in to allow all kinds of messing with how the output is displayed. From a simple "Recent Posts" block on your page to displaying upcoming events from your calendar plugin to showing the most visited job postings, WPQuery Shortcode makes it easy.


The most basic example is this:


Which returns the following HTML by default:

<div class="wqs_list">
    <ul class="wqs_list_post_wrap">
+--     <li class="wqs_list_post_item">
|           <a href="…" class="wqs_title">Title One</a>
| 5x        <span class="wqs_list_wqs_excerpt">
|               <p>This is the excerpt text.</p>
|           </span>
+--     </li>

If you want to use a section tag instead of a div tag, use the following filters to override the defaults:

function wqs_wrapper_start($class) {
    return "<section class=\"{$class}\">";
WQSDefaults::remove_filter('wqs_wrapper_start');        // Removes the default filter
add_filter('wqs_wrapper_start', 'wqs_wrapper_start');

function wqs_wrapper_end() {
    return "</section>";
WQSDefaults::remove_filter('wqs_wrapper_end');          // Removes the default filter
add_filter('wqs_wrapper_end', 'wqs_wrapper_end');

If you want to use the plugin within another plugin or directly from your functions.php file in order to save yourself some trouble with The Loop:

WQSDefaults::remove_all_filters();                      // Removes all default filters
// Add your own filters here.
$wqs = WQS::get_instance();
$items = $wqs->wqs(array(
    'cat' => 3,
    // More WP_Query parameters here
), 'Some header text here', TRUE);                      // Third param returns an array instead of a string.
foreach ($items as $id => $item) {
    // do stuff

Requires: 3.5 or higher
Compatible up to: 3.8.18
Last Updated: 3 years ago
Active Installs: 10+


0 out of 5 stars


Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.