• Resolved kimo50asa

    (@kimo50asa)


    Hi there,

    I need some helping adding an image above EACH category content section and below the header. I would like to add a 800×200 image across each of the blog sections.

    Thank you so much to anyone that can help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello there.

    This is a rather complex modification which I’m afraid, as authors, can’t provide ready made code for.

    I can give you some pointers on how something like this could be implemented.

    You can start by finding a plugin that allows you to add featured images to WordPress categories. Check the repo here https://www.ads-software.com/plugins/tags/category-image

    Once you find one you can use its documentation to help you see how you can output that image in a template.
    Use that code in the index.php file, perhaps below line 8 (depending on where you want the image to appear) to echo the image.

    Perhaps you could consider a conditional statement to check if a category listing is displayed https://codex.www.ads-software.com/Conditional_Tags#A_Category_Page so the code runs only on category listings and not all the time.

    Thread Starter kimo50asa

    (@kimo50asa)

    Hi @nvourva

    what i need, is to add the image in the category pages below the header, not as featured images.

    so, when I searched earlier i found out that i can use this code below

    <?php if ( is_category( ‘2’ ) ) { ;?>
    <?echo ‘<img src=“images/cat2.jpg” width=“800” height=”200″>’;?>
    <?php } elseif ( is_category( ‘3’ ) ){ ;?>
    <?echo ‘<img src=“images/cat3.jpg” width=“800” height=”200″>’;?>
    <?php } elseif ( is_category( ‘4’ ) ){ ;?>
    <?echo ‘<img src=”images/cat4.jpg” width=“800″ height=“200″>’;?>
    <?php } else { ;?>

    <?php } ;?>

    but am not sure where to add it, i try to put it in page.php , header.php but it didn’t work.
    i don’t know if could help me

    thanks in advance

    This is interesting.

    In requires, of course, coding. To be able to add banner images below your header, check out wp_head action. Like:

    <?php
    
    add_action('wp_head', 'add_header_banner');
    
    function add_header_banner() {
    echo '<img src="#" alt=""';
    }
    
    Of course, it will be more complicated than that... if you want admin interface etc.
    
    ?>

    For the content, you need to add_filter on the_content here.
    To give each category a different banner, you’ll use is_category here and probably switch statements and the like.

    Thread Starter kimo50asa

    (@kimo50asa)

    @Jowett Isaiah Go

    thank you

    unfortunately am not expert in coding, so i have no idea how to do the steps above and where.

    if you could explain it that will safe me lots of search ??

    thank you again

    The code you found can be used in the index.php file, just below line 8 as suggested.
    However I would suggest changing the
    <?echo
    bits to
    <?php echo

    Thread Starter kimo50asa

    (@kimo50asa)

    @nvourva

    man, you are my HERO
    thank you very much for your support.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding Image Above Category content and below header’ is closed to new replies.