0

I have a WP installation with 6 categories and I want 3 of them to use a custom Category Archive Page called "category-special.php" (default page is the "category.php"). I found the code below that looks to be close to my query, how can I modify and make it work for me, so categories 31,40 and 55 to load the above specific page?

add_filter( 'template_include', 'wpsites_photo_page_template', 99 );
function wpsites_photo_page_template( $template ) {
    if ( is_category('33') ) {
        $new_template = locate_template( array( 'photo.php' ) );
        if ( '' != $new_template ) {
            return $new_template ;
        }
    }
    return $template;
}

Thank you.

0

you can use the category-slug.php file name if you want to have a custom page for each category

https://codex.wordpress.org/Category_Templates here is a link that will help you.

  • I know that but I want to have 3 categories with the same page layout and another 3 with other, so it is not practical. – geoplous Jul 10 '17 at 4:35
  • That can be done with a if statement so like if catagrery name is 33 the load cateagry-33.php elseif catagery name is 34 then load categery-34.php – Elroy Fernandes Jul 10 '17 at 5:18
  • same problem here as a I have to create 3 different files with the same content – geoplous Jul 10 '17 at 5:59
0

try bellow code :

add_filter( 'template_include', 'wpsites_photo_page_template', 99 );
function wpsites_photo_page_template( $template ) {
    if ( is_category('31') || is_category('40') || is_category('55') ) {
        $new_template = locate_template( array( 'photo.php' ) );
        if ( '' != $new_template ) {
            return $new_template ;
        }
    }
    return $template;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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