Feed from Multiple Post Categories Using one Template

global $post;
$name = get_post( $post )->post_name;
$args = array(
	'post_type' => 'post',
	'orderby' => 'date',
	'order' => 'DESC',
 	'category_name' => $name 
$post_feed = get_posts($args);

This handy bit of code will allow you to pull posts into multiple template pages, using multiple categories (child categories feeding into the parent categories) and display them only on the relevant page of the same name as the Category. You can create as many categories as you want, and they will only feed onto the template pages of the same name. Can I get an amen?

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.