Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1232133
    TinBerakovicRacing
    Participant

    Hello,

    I would like to post a banner image right where the Post Slider should be but i want it to be a static image with no caption or link. I would also like to have a different image for each category archive and page (i have 4 categories and 1 page)

    Is there a way to do it?

    #1232217
    Nabeel A
    Moderator

    Hi there,

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    #1232523
    TinBerakovicRacing
    Participant
    #1232678
    Rad
    Moderator

    Hi there,

    Please add this code to your child theme’s functions.php

    add_actio('x_before_view_ethos__post-slider', 'the_static_banner');
    
    function the_static_banner () {
    
    if ( is_category() ) {
    
    global $wp_query;
    
    $images = array (
    
    232 => 'http://example.com/path/to/the/image.jpg',
    235 => 'http://example.com/path/to/the/image.jpg',
    237 => 'http://example.com/path/to/the/image.jpg',
    
    ); 
    
    $current_image = $images[ $wp_query->get_queried_object_id() ];
    
    if ( !empty( $current_image ) ) {
    
    echo '<div class="category_banner"><img src="'.$current_image.'"></div>';
    
    }
    
    }
    
    }

    Then change this part to add your category ID and its image banner’s URL.

    array (
    
    232 => 'http://example.com/path/to/the/image.jpg',
    235 => 'http://example.com/path/to/the/image.jpg',
    237 => 'http://example.com/path/to/the/image.jpg',
    
    ); 

    Cheers!

    #1233289
    TinBerakovicRacing
    Participant

    I’ve added this to child theme and the images aren’t showing on either the homepage or the category archives

    #1233550
    Jade
    Moderator

    Hi there,

    I have tried to check on your site and it seems to be inaccessible at the moment.

    Kindly double check so that we could check it on our end.

    #1235937
    TinBerakovicRacing
    Participant

    It’s working for me.
    Should I send you login information?

    #1236005
    Thai
    Moderator

    Hi There,

    Please provide us with your admin account & password.

    Thanks.

    #1237018
    TinBerakovicRacing
    Participant
    This reply has been marked as private.
    #1237306
    Rue Nel
    Moderator

    Hello There,

    Please modify the code and use these lines:

    
    array (
    
      3 => 'http://example.com/path/to/the/image.jpg',
      7 => 'http://example.com/path/to/the/image.jpg',
      6 => 'http://example.com/path/to/the/image.jpg',
      4 => 'http://example.com/path/to/the/image.jpg'
    
    ); 

    3, 7, 6, 4 is the category ID. To get the category ID, please check this out: https://community.theme.co/kb/how-to-locate-category-ids/

    Hope this helps.

    #1237957
    TinBerakovicRacing
    Participant

    This worked for the categories, thanks, but I would like it to show on the homepage as well

    #1237994
    TinBerakovicRacing
    Participant

    Also can it appear over the title of the category instead of under it?

    Thank you so much!

    #1238154
    Nabeel A
    Moderator

    Hi again,

    1. To display the title over the banner image, add this code in your Customizer via Appearance > Customize > Custom > Edit Global CSS:

    
    .category_banner {
        margin-top: -110px;
        float: left;
    }
    .category .h-landmark span {
        color: white !important;
        position: relative;
        z-index: 1;
        padding: 20px;
    }

    2. To add the banner on homepage, just add the following jQuery script in your Customizer via Appearance > Customize > Custom > Edit Global Javascript

    jQuery(document).ready(function($){
    	$('.home .x-container.max.width.main').prepend('<img src="https://s-media-cache-ak0.pinimg.com/originals/5f/85/29/5f85292b3dfb0fdbc6c10a5ea253ddc2.jpg">');
    });

    Don’t forget to clear your browser’s cache after adding the code. Let us know how this goes!

  • <script> jQuery(function($){ $("#no-reply-1232133 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>