Plugin Directory

Test out the new Plugin Directory and let us know what you think.

Inject Query Posts

Inject an array of posts into a WP query object as if queried, particularly useful to allow use of standard template tags.

2.2.4 (2016-01-25)

  • New: Create empty index.php to prevent files from being listed if web server has enabled directory listings.
  • New: Add 'Text Domain' header attribute.
  • Change: Note compatibility through WP 4.4+.
  • Change: Explicitly declare methods in unit tests as public.
  • Change: Update copyright date (2016).

2.2.3 (2015-08-14)

  • Bugfix: 'c2c_inject_query_posts' hook should be a filter and not an action
  • Update: Correct documentation regarding 'c2c_inject_query_posts' hook
  • Update: Minor inline document tweaks (spacing)
  • Update: Add full inline documentation to provided example
  • Update: Note compatibility through WP 4.3+

2.2.2 (2015-02-11)

  • Note compatibility through WP 4.1+
  • Update copyright date (2015)

2.2.1 (2014-08-25)

  • Minor plugin header reformatting
  • Minor code reformatting (spacing, bracing)
  • Change documentation links to wp.org to be https
  • Note compatibility through WP 4.0+
  • Add plugin icon

2.2 (2013-12-17)

  • Change default of $preserve_query_obj argument to false, meaning that the query object getting injected will be reset before doing so
  • Remove manual resetting of WP_Query variables since the class's init() does it all
  • Support passing a WP_Post object as the first argument
  • Add unit tests
  • Note compatibility through WP 3.8+
  • Drop compatibility with versions of WP older than 3.6
  • Update copyright date (2014)
  • Add banner
  • Change donate link
  • Minor code formatting changes (bracing)
  • Minor formatting changes (spacing) and code example changes in readme.txt


  • Rename inject_query_posts() to c2c_inject_query_posts() (but maintain a deprecated version for backwards compatibility)
  • Add filter 'c2c_inject_query_posts' so that users can use the do_action('c2c_inject_query_posts') notation for invoking the function
  • Add optional $cache_posts argument to function and use it determine if update_post_caches() should be called
  • Add better control for specifying arguments to update_post_caches()
  • Send $posts and $config as additional args to 'inject_query_posts_preserve_query_obj' filter
  • Add check to prevent execution of code if file is directly accessed
  • Update documentation
  • Note compatibility through WP 3.5+
  • Update copyright date (2013)


  • Re-license as GPLv2 or later (from X11)
  • Add 'License' and 'License URI' header tags to readme.txt and plugin file
  • Remove ending PHP close tag
  • Note compatibility through WP 3.4+


  • Note compatibility through WP 3.2+
  • Add link to plugin directory page to readme.txt
  • Update copyright date (2012)


  • Remove unnecessary reset of meta_query and tax_query query object variables


  • Note compatibility through WP 3.2+
  • Minor code formatting changes (spacing)
  • Fix plugin homepage and author links in description in readme.txt


  • Note compatibility through WP 3.1+
  • Update copyright date (2011)


  • If no query_obj is sent, use the global $wp_query object (previously used to create a new query object)
  • If a not-false, non-object value is sent as $wp_query object (namely any non-empty string or non-zero integer), then create a new WP_Query object for use
  • Add ability to preserve the state of the existing query_obj
    • Add $preserve_query_obj arg (optional) to inject_query_posts(), default to true
    • Add filter 'inject_query_posts_preserve_query_obj' that gets passed value of $preserve_query_obj
  • Reset more query_obj settings
  • Wrap function in if(!function_exists()) check
  • Remove docs from top of plugin file (all that and more are in readme.txt)
  • Minor code reformatting (spacing)
  • Add PHPDoc documentation
  • Note compatibility with WP 2.8+, 2.9+, 3.0+
  • Update copyright date
  • Add package info to top of plugin file
  • Add Changelog, Filters, Template Tags, and Upgrade Notice sections to readme.txt
  • Remove trailing whitespace
  • Add to plugin repo


  • Initial release

Requires: 3.6 or higher
Compatible up to: 4.5.5
Last Updated: 9 months ago
Active Installs: 20+


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.