• Resolved Daniel

    (@ddumondgmailcom)


    Hello,

    I have a theme based restaurant menu and I’d like to add some additional information after the post for that specific category.

    For example…

    <?php if (is_category('white')) : ?>
    <p>White wine is yummy!</p>
    <?php endif; ?>

    The problem is, it doesn’t work.

    If I do:

    <?php if (is_archive('white')) : ?>
    <p>White Wine is yummy!</p>
    <?php endif; ?>

    It works, but it displays on all archive pages.

    I’m guessing I need to specify the category of the custom post type which would be “wines” but I’m just not sure how to implement it.

    I have very little knowledge of php, so any help would be appreciated.

    Thank you!

Viewing 4 replies - 16 through 19 (of 19 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Ah, try it with is_tax():
    https://codex.www.ads-software.com/Function_Reference/is_tax

    <?php if(is_tax( 'menu_type', 'kids-menu' ) ) : ?>
    <p>A portion of all meals will go to the Montreal Children's Hospital Foundation.</p>
    <?php endif; ?>

    Thread Starter Daniel

    (@ddumondgmailcom)

    HA HA!!!!! keesiemeijer, you freekin’ GENIUS!!! It worked!!!!

    I REALLY appreciate your persistence!!!! If you ever find yourself in Cornwall, the first 10 beers are on me!!! ??

    Thank you! Thank you! Thank you!!!!!!! ??

    Moderator keesiemeijer

    (@keesiemeijer)

    You’re welcome ?? I also found another solution by adding an extra description field to the taxonomy “menu_type” edit page.
    If you want you can put this in your theme’s functions.php: https://pastebin.com/gbucRFL7

    Add the descriptions to the terms and use a conditional as this to show the extra description:

    <?php if (get_term_extra_description()) : ?>
    <p><?php echo get_term_extra_description(); ?></p>
    <?php endif; ?>

    I’m glad you’ve got it resolved.

    Thread Starter Daniel

    (@ddumondgmailcom)

    Heck! You just don’t stop giving, do you?! ??

    I’m glad you shared this as an alternate solution! This would be a great option if the client is the one doing the editing allowing them to easily include additional category information in a separate area!

    Great share! Thanks again keesiemeijer! ??

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Display text based on category of custom post’ is closed to new replies.