• Resolved vincentlopy

    (@vincentlopy)


    Is it possible have multiple search templates based on post type?

    I places this code in search.php

    <?php
    if( get_post_type() == 'dog' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'cat' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'wolf' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'leon' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'tiger' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'panther' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'mouse' ) {
    include( TEMPLATEPATH.'/search3.php' );
    }
    ?>

    Seems that works but when I do a research without results I get blank page. I dont know why! Can you help me please?

Viewing 1 replies (of 1 total)
  • Thread Starter vincentlopy

    (@vincentlopy)

    I resolved myself this issue and FREE!!

    This is correct code:

    <?php
    if( get_post_type() == 'dog' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'cat' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'wolf' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'leon' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'tiger' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'panther' ) {
    include( TEMPLATEPATH.'/search2.php' );
    }else if ( get_post_type() == 'mouse' ) {
    include( TEMPLATEPATH.'/search3.php' );
    }else if ( get_post_type() == '' ) {
    include( TEMPLATEPATH.'/search4.php' );
    }
    ?>

Viewing 1 replies (of 1 total)

The topic ‘search templates based on post type’ is closed to new replies.