• Resolved petehawk

    (@petehawk)


    Great plugin – just what I was looking for and fits with the latest version of WP like a glove, thank you.

    I have three menus set up on theredlionlitton.co.uk/our-food-at-the-red-lion-litton/ and want to set the header image relevant to the page content.. i.e. a for one for the menus. Using conditional statements to do this.

    So the question what are these menus? Are they pages, posts within the ‘menu’ category, or what. I currently have the statements working with an is_single statement (which suggests they are posts and not pages) that sets the correct image, but this sets all single posts with the same header and for the event posts I’d rather have another image.

    If that made sense, I’d appreciate your thoughts.

    Thanks

    Pete

    https://www.ads-software.com/plugins/food-and-drink-menu/

Viewing 6 replies - 1 through 6 (of 6 total)
  • NateWr

    (@natewr)

    Hi Pete, thanks for the kind words!

    Each menu is a Custom Post Type named “fdm-menu”. If you’re checking this from within The Loop, you can use the following code to check if it’s a menu post type:

    <?php if ( is_single() && 'fdm-menu' == get_post_type( get_the_ID() ) : ?>

    Let me know if you have any more questions.

    Thread Starter petehawk

    (@petehawk)

    Thanks for the prompt response NateWr.

    <?php elseif (is_single() && 'fdm-menu') ==get_post_type(get_the_ID() ) : ?>
    <img src="<?php bloginfo('template_url'); ?>/images/sunday-roast.jpg" width="740" height="200" alt="<?php the_title_attribute(); ?>">

    Tried the above and it’s not playing so Im obviously misunderstanding something here.

    All help appreciated

    Pete

    NateWr

    (@natewr)

    There are a couple typos in there. Right after ‘fdm-menu’ you have an unnecessary ), so remove that. Then add a space between “==” and “get_post_type”.

    Thread Starter petehawk

    (@petehawk)

    now getting ann error message

    Parse error: syntax error, unexpected ‘;’ in /home/theredli/public_html/wp-content/themes/redun/headerimage.php on line 20
    with`<?php elseif (is_single() && ‘fdm-menu’ == get_post_type(get_the_ID() ): ?>
    <img src=”<?php bloginfo(‘template_url’); ?>/images/sunday-roast.jpg” width=”740″ height=”200″ alt=”<?php the_title_attribute(); ?>”>
    `

    Pete

    NateWr

    (@natewr)

    Add another closing parentheses just before the colon at the end:

    <?php elseif (is_single() && 'fdm-menu' == get_post_type(get_the_ID()) ): ?>

    Thread Starter petehawk

    (@petehawk)

    Fabulous.. got it.. need to put it before the normal is_single statement and all is well… Just need to tidy it all up and another satisfying day.

    Thanks for your help

    Pete

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Are they pages, posts categories or what?’ is closed to new replies.