WordPress.org

Support

Support » How-To and Troubleshooting » Adding a banner above posts

Adding a banner above posts

  • Hello there.

    I was wondering if there is any way that i can add a banner above posts of a specific category.

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Hi chrisntoukas,

    One way you can do this is by following these steps:

    1. Create a child theme;
    2. duplicate single.php from the parent to the child (create a file called single.php and copy all of the content from single.php in the parent theme into single.php in the child theme);
    3. In single.php in the child theme, find the place where you want the banner ad to appear and add the following snippet

    <?php if (in_category ('category1')) {  ?>
    	<div class="banner-ad">
    	 This is a banner ad
    	</div>
    
    <?php } ?>

    On the basis of the code above, if we’re viewing a post in category 1, a banner ad will be displayed.

    Obviously, you will adapt the category slug (the category name) and the mark-up for the banner ad to your own needs.

    I hope it helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Adding a banner above posts’ is closed to new replies.
Skip to toolbar