WordPress.org

Ready to get started?Download WordPress

Plugin Directory

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.

Examples

The most basic example is this:

[wqs][/wqs]

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>
    </ul>
</div>

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.3
Last Updated: 2013-12-13
Downloads: 302

Ratings

0 stars
0 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

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