0

I want to create a template for category page for custom post type. I have tried with category-my-campcat.php and taxonomy-my-campcat.php.

But when I click on category then it redirect to category.php page.

Also How can I check that I am on category page in wordpress. from is_category() ??? I have tried it but no success...

6
  • Ahh it was working. but I found a new problem. I am using below code to use my own template for detail page of my custom post ` function my_search_template_redirect() { global $post; if ($post->post_type == 'my_camp' && !is_search() ) { $templatefilename = 'my_camp-template.php'; $return_template = dirname(FILE) . '/my_templates/' . $templatefilename; do_theme_redirect($return_template); }} add_action('template_redirect', 'my_search_template_redirect', 1); ` But here how can I check for category page here like: if ($post->post_type == 'my_camp' && !is_search() && !is_category() )
    – avinashphp
    Commented Feb 18, 2014 at 11:43
  • what is the post type?
    – Arvind Pal
    Commented Feb 18, 2014 at 11:45
  • post type: my_camp
    – avinashphp
    Commented Feb 18, 2014 at 11:50
  • have u tried this file name taxonomy-my-camp.php
    – Arvind Pal
    Commented Feb 18, 2014 at 11:55
  • Please read this post wordpress.org/support/topic/…
    – Arvind Pal
    Commented Feb 18, 2014 at 11:57

1 Answer 1

0

Solved

I alter my code and use below code to check :

if ($post->post_type == 'my_camp' && is_single() ) {

Now it will check only for my_camp post type at post detail page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.