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://ww.wp.xz.cn/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.ww.wp.xz.cn/Conditional_Tags#A_Category_Page so the code runs only on category listings and not all the time.
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.
@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
@nvourva
man, you are my HERO
thank you very much for your support.