Adding a banner above posts (2 posts)

  1. chrisntoukas
    Posted 1 year ago #

    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.

  2. Maria Antonietta Perna
    Posted 1 year ago #

    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
    <?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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.