Jump to content
Sign in to follow this  
aureacode

Advanced custom post type layuot (a layuot for each custom post type)

Recommended Posts

aureacode

Hello. I have two custom sections (services, promotions), each is linked to a custom post type, what I need is to have a different template for each post type. I overwrote the "template.postloop.php" file, and i make a validation to load the appropriate template:

if (get_post_type ($ post-> ID) == "services"){
	get_template_part ('template.services');
	return;
	}
	..........

Everything works fine. My problem is that need that each template has a different layout: services => fullwidth promotions => a left sidebar In the layout editor I can only choose one (Default Layout Mode) I know the layout can be chosen for each post or page created in the options, but in this case ??how can i tell that each template has a different layout?. Greetings!

Share this post


Link to post
Share on other sites
cmunns

You could do it with jQuery to modify the class after the page loads. Adding this hook would work ` add_action ('wp_footer','cat_layout'); function cat_layout(){?> <?php if (is_category()):?> <?php endif;?> <?php } ` Just specify the category or change it to a post type in the conditional statement.

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  

×