4.0Essential Grid 4.0 is here — see what’s new

FAQ

Auto-populate Grid for Blog Pages Outside “The Loop” (advanced)

Essential Grid 3 · The 4.0 FAQ

If you want to use Essential Grid for the Blog, Category, Archive, Tags, Author, Search pages of your theme, the following code snippet can be added to your corresponding theme files.

This example is for adding the custom code outside The Loop. For an “inside The Loop” example, Click Here

if(is_tag()) $my_posts = get_posts(array('tag' => get_query_var('tag')));
else if(is_author()) $my_posts = get_posts(array('author' => get_query_var('author')));
else if(is_date()) $my_posts = get_posts(array('m' => get_query_var('m')));
else $my_posts = get_posts(array('cat' => get_query_var('cat')));

$my_post_ids = array();

foreach($my_posts as $post) {
   array_push( $my_post_ids, $post -> ID );
}

echo do_shortcode('');

Example of the snippet added to the TwentyFifteen theme’s “archives.php” file.

This code can also be added to another one of your theme’s php files, such as “category.php”, “index.php”, etc.

Black Friday

30% off your first year of Essential GridBlack Friday: 30% off Until Ends tonight

See the offer