• Resolved bigcityjohn

    (@bigcityjohn)


    I’m trying to add a sponsor banner on a particular Category archive page, and it should appear just above the posts on that specific category page. I’m using the following code in my functions.php file, but the banner is appearing above each and every post on that page rather than just above the first one.

    Can someone please let me know what I’m doing incorrectly? Or, if there’s a better/more concise way of doing this, please feel free to share.

    function sponsor_banner($post_count) {
    if (is_category('category-xyz')) {
    if ($post_count == 1) { ?>
    <img src="/path/to/banner.jpg">
    <?php
    }
    }
    }
    add_action('the_post', 'sponsor_banner');
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Need to add sponsor banner before posts on Category archive page’ is closed to new replies.