• Hi people.
    (website is http://www.myrevive.co.uk)
    I am trying to remove the header images in some of the pages in my twenty eleven theme. I have managed to remove one on page 20 by using this

    <?php if( !is_page( 20 ) ) : ?>'
    and '<?php endif; ?>' wrapped around this:-
    '<?php
    // Check to see if the header image has been removed
    $header_image = get_header_image();
    if ( $header_image ) :
    // Compatibility with versions of WordPress prior to 3.4.
    if ( function_exists( 'get_custom_header' ) ) {
    // We need to figure out what the minimum width should be for our featured image.
    // This result would be the suggested width if the theme were to implement flexible widths.
    $header_image_width = get_theme_support( 'custom-header', 'width' );
    } else {
    $header_image_width = HEADER_IMAGE_WIDTH;
    }
    ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

    BUT i want to add other pages ID’s to this conditional tage. So it gives me the option to remove headers on pages I want.

    Ive tried using this ‘<?php if( !is_page( array( 14, 20 ) ) : ?>’

    but it does not seem to work. Can someone please let me know what I am doing wrong with this?

    Thanks in advance

    Kind regards
    website is http://www.myrevive.co.uk

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter apollo_24

    (@apollo_24)

    hi esmi, sorry I wanted to update my first post, but couldnt delete it so started this new post.

    Do you have any info info the problem with the conditional code I am using?

    I am using a child theme at the moment for it.

    thanks in advance

    One way would be to use :
    `<?php if(( !is_page( 20 ) )&&( !is_page( 14 ))) : ?>’
    and so on, but this is not the most elegant solution but it should be better then no solution.

    Regards

    Try using custom fields instead so that you can control this on an ad-hoc basis.

    Thread Starter apollo_24

    (@apollo_24)

    thanks jnhghy

    and to esmi, how would I obtain the result in the custom field section? Iv e not used that before

    Did you have a look at the page I linked to above?

    Thread Starter apollo_24

    (@apollo_24)

    Ive read the link twice now. Ime very new at wordpress and find it quite difficult to user stand most of it. Im managed to learn a few things about editing codes ect. But the custom fields link even after i read it was still unable to udnerstand.

    sorry

    OK – let’s assume you set up a custom field called ‘no_header_imageon Page ID 20 with a value ofyes. Then instead of<?php if( !is_page( 20 ) ) : ?>`, you could use something like:

    <?php if( get_post_meta($post->ID) && get_post_meta($post->ID) == 'yes' ) :?>

    Then, you add/remove this custom field to any Post or Page that you wanted and the header wouldn’t be shown.

    Thread Starter apollo_24

    (@apollo_24)

    Sorry for late reply, have been away. Ok I have taken out `<?php if(( !is_page( 20 ) )&&( !is_page( 14 ))) : ?>’
    and replaced it with
    <?php if( get_post_meta($post->ID) && get_post_meta($post->ID) == ‘yes’ ) :?>
    and then on a sample page added the custom field as suggested. But now it seems to take the header off all of the pages.

    I must be doing something wrong (as usual) but what Im not sure. Any ideas?

    [ 1 hour and you’re bumping? Please do not bump, it’s not permitted here. ]

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Conditional tags in header file. Help appreicated’ is closed to new replies.