Jump to content
Sign in to follow this  
strategicblend

What is the easiest way to create a category filter on the default news/blog template?

Recommended Posts

strategicblend

In most cases, a client will want to have the news/blog page only pull from a few specific categories. I'm still not understanding how PP's news/blog template works - what is recommended for the best cat query code and where should it be placed? Thanks!

Share this post


Link to post
Share on other sites
kastelic

First enable the base child theme and paste this into platformbase/functions.php. Replace the 1 2 and 3 with your won category id's.

	//Removes certain categories from home page based on category id
	add_action('pagelines_inside_top_theloop' ,'filter_cats');
	function filter_cats(){
		if (is_home()){
			$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //fixes pagination
			$args = array(
				'cat'=> '-1,-2,-3',
				'paged'=> $paged
			);
			query_posts($args);
		  }
	}
	
	

Share this post


Link to post
Share on other sites
strategicblend

That seems to work, thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×