>
Download This Plugin | |
Download Elegant Themes | |
Name | Inject Query Posts |
Version | 2.2.2 |
Author | Scott Reilly |
Rating | 0 |
Last updated | 2015-02-12 07:23:00 |
Downloads |
1353
|
Download Plugins Speed Test plugin for Wordpress |
Home page PageSpeed score has been degraded by 0%, while Post page PageSpeed score has been degraded by 0%
Inject Query Posts plugin added 15 bytes of resources to the Home page and 14 bytes of resources to the sample Post page.
Inject Query Posts plugin added 0 new host(s) to the Home page and 0 new host(s) to the sample Post page.
Great! Inject Query Posts plugin ads no tables to your Wordpress blog database.WordPress's template tags are intended to be used within 'the loop'. The loop is managed by a WP_Query object which sets up various global variables and its own object variables for use by the various template tags. The primary purpose of a WP_Query object is to actually query the database for the posts that match the currently specified criteria. However, if you don't need to query for posts since you already have them by some other means, you can still take advantage of the template tags by injecting those posts into the WP_Query via this plugin.
Depending on the template tags you are looking to use, or the logic you are hoping to employ within a loop, you may need to manually configure some of the query object's variables.
Example:
<?php // Say we're in the sidebar
// We've gotten some post objects on our own.
$posts = c2c_get_random_posts( 5, '' );
// Inject the posts
c2c_inject_query_posts( $posts );
// Now let's display them via template tags:
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
<?php endif; ?>
Links: Plugin Homepage | Plugin Directory Page | Author Homepage