Jump to content

Archived

This topic is now archived and is closed to further replies.

sqsatg

Category template + custom post type

Recommended Posts

sqsatg

Hello :)

 

I am working on a website which has classic posts and custom posts named event. The posts and the events share same category.

 

First, I followed this tutotial to have different template for different category :http://wphtml5.com/pageline-dms-how-to-create-different-template-for-different-category/ and it works very well !

 

Then, I followed the Wordpress Codex with this code, add a 'is_category()' in order to show posts and events in the home page and category page.

// Show posts of 'post', 'page' and 'event' post types on home page
add_action( 'pre_get_posts', 'add_my_post_types_to_query' );

function add_my_post_types_to_query( $query ) {
  if ( (is_home() || is_category()) && $query->is_main_query() )
    $query->set( 'post_type', array( 'post', 'page', 'event' ) );
  return $query;
}

And it works too ! The posts and the events are both display.

 

But, together, it doesn't work as I wish : in category pages, posts and events of same category are shown, but the specific template doesn't work anymore. 

 

Can someone help me please ?

 

Regards.

Share this post


Link to post
Share on other sites
Danny

Hi,

 

It is not currently possible to have categories to have different templates. The guide you have followed is for DMS 1.x and requires you to edit core files which is something we do not recommend nor support.

 

The issue regarding custom category pages has been reported to our tracker and our developers are aware of this feature request.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

×