Query Posts is a widget that allows you to display posts in any way you want.
This is the first official release of the plugin. Much of it is experimental, and I do value feedback on what could make it better. Although it is experimental, the plugin is very stable. Follow this guide to get your widget up and running. If something's not covered here, there are plenty of links with extra information to help you along.
query-posts.zip folder.query-posts folder to your /wp-content/plugins directory.There are several settings for the widget. You need to know how the query_posts() function works to use them. You need at least a very basic understanding of its parameters to even use this widget.
showposts — number of postsposts_per_page — how many posts per pageorder — order posts in ascending or descending orderorderby — what the posts should be ordered byoffset — how many posts to skip overpaged — show posts from a particular page (i.e. page 1, 2, 3, etc.)p — post IDname — post slugpage_id — page IDpagename — page pathpost__in — comma-separated array of post IDspost__not_in — comma-separated array of post IDscaller_get_posts — true or false (true excludes stickies)cat — category ID(s)category_name — category name/slugcategory__and — array of comma-separated category IDscategory__in — array of comma-separated category IDscategory__not_in — array of comma-separated category IDstag — tag slug(s)tag__and — array of comma-separated tag IDstag__in — array of comma-separated tag IDstag_slug__in — array of comma-separated tag slugstag_slug__and — array of comma-separated tag slugsauthor_name — user nicenameauthor — user IDyear — integermonthnum — integerw — integerday — integerhour — integerminute — integersecond — integermeta_key — the name of the custom field keymeta_value — the value of the custom fieldmeta_compare — operator to test the meta_value.This is not required but could be fun to do.
To truly understand how powerful this plugin is, you might want a widgetized page template, or several. My Hybrid theme has one of these. I'll give you a quick tutorial here. For more information on page templates, read this tutorial on page templates.
The first thing you want to do is create a new widget section. So, open your theme's functions.php file and add this code:
<?php
register_sidebar( array(
'name' => 'Widgets Template',
'id' => 'widgets-template',
'before' => '<div id="%1$s" class="widget %2$s widget-%2$s">',
'after' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title', => '</h3>'
) );
?>
Save your functions.php file.
Then, you need to create a new file in your theme's root folder named page-widgets.php. The best method is to copy your theme's page.php file and mold this code into it. Here is an example:
<?php
/*
Template Name: Widgets
*/
get_header(); ?>
<div class="content">
<?php dynamic_sidebar( 'widgets-template' ); ?>
</div>
<?php get_footer(); ?>
I run a WordPress community called Theme Hybrid, which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($25 USD at the time of writing).
I know. I know. You might not want to pay for support, but just consider it a donation to the project. I am fully employed through my work with WordPress, so to continue making cool, GPL-licensed plugins and having the time to support them, I must pay the bills.
Query Posts is licensed under the GNU General Public License, version 2 (GPL).
This plugin is copyrighted to Justin Tadlock.
2009 © Justin Tadlock