Forums

[resolved] Can't Get Category ID in Footer (3 posts)

  1. kamoh
    Member
    Posted 1 year ago #

    I'm trying edit my template to display a different image depending on the category of the post, and though this is working fine in the header, I can't get it to work in the footer. I've figured out that this is being caused by something in the tabbed navigation code above it, but haven't been able to see what yet. I'd appreciate any help on this!

    The code I'm using to display different images in the footer depending on the category ID (and verified working in the header) is:

    <?php if ( is_front_page('home') ) { ?>
    	<div><img src="http://www.mysite.com/main_page_image.jpg"></div>
    <?php } elseif ( in_category('3') ) { ?>
    	<div><img src="http://www.mysite.com/category_3_image.jpg"></div>
    <?php } else { ?>
       <img src="http://www.mysite.com/catchall_image.jpg">
            <?php } ?>

    This is the code for the tabbed navigation that is obstructing this in the footer:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    your 'tabbed' code is probably distorting the original $query_string;
    try to add a 'wp_reset_query();' before your code in the footer.

  3. kamoh
    Member
    Posted 1 year ago #

    That did the trick, thank you so much!

    Solving my problem + super fast reply = I heart this community.

Topic Closed

This topic has been closed to new replies.

About this Topic