• I’m trying to use an old switch I used before, but am confused as to why it’s not working? I have a different Permalink Structure. %Post_Id%/%Postname% I’m wondering if I need to re-write the switch to pull Postnames instead. As the switch currently only shows the default image.

    Would anyone be willing to help me solve this riddle. Normally this would work if the URL had a Post Id displayed in the URL bar in the browser.

    <? switch( $_GET['post_id'] ) {
    
    case 19:
    $image_url = 'http://greenecountyohio.org/wordpress/wp-content/themes/greenecountyohio/images/jpg/military_header.jpg';
    break;
    
    default:
    $image_url = 'http://greenecountyohio.org/wordpress/wp-content/themes/greenecountyohio/images/jpg/where_to_header.jpg';
    }
    ?>

    I’m thinking something like this would have worked but it does not seem to do the trick. Changing the last thing in the URL that it’s looking for. the post_id to postname instead. and having the case search for a name rather a number.

    <? switch( $_GET['postname'] ) {
    
    case "military":
    $image_url = 'http://greenecountyohio.org/wordpress/wp-content/themes/greenecountyohio/images/jpg/military_header.jpg';
    break;
    
    default:
    $image_url = 'http://greenecountyohio.org/wordpress/wp-content/themes/greenecountyohio/images/jpg/where_to_header.jpg';
    }
    ?>

    Any thoughts as to what I might be doing wrong??

The topic ‘Using A Case Switch for Headers’ is closed to new replies.