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

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.

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

Further Resources for Web Design and Development Enthusiasts

Alright! We've embarked on quite an adventure exploring the realms of this topic. But why stop there? The world of web design and development is vast, and there's always more to learn and discover. Let's dive into some resources that'll keep your knowledge fresh, your skills sharp, and your passion ignited:

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

Liked this Post?
Please Share it!