Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1371025

    Hi,

    I added a banner on my blog page with a title and a photo in the background. I would like to have the same banner on the different categories of blog posts. And if possible, put the name of the category instead of the title “The Blog”

    Capture of the banner on the blog page : https://drive.google.com/file/d/1UZpNzgHRliTQCHWI-89enWzUP1ZOLqF6/view?usp=sharing
    Capture of the category page : https://drive.google.com/file/d/1g9yyCAmffSS_fq3S2tz-ClledCKgXiEf/view?usp=sharing

    I add my credentials in the private content,

    Thank you very much,
    Best regards

    Audrey

    #1371279

    Hey laboiteapixels12,
    Thank you for the login to your site, but it is not an admin login so I was limited.
    I see that on your category pages you are displaying the category description and I assume that you would like this as the title in the banner image like the blog page is displayed.
    Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function custom_category_banner() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
    (function($){
      $('#top.archive.category').each(function() {
      	var catTitle = $('.category-term-description p').text();
      	var catBanner = $('<div class="avia-section avia-full-stretch fullsize cat-banner"><div class="av-section-color-overlay-wrap"><div class="av-section-color-overlay"></div></div><h1>'+ catTitle +'</h1></div>');
      	$(catBanner).insertBefore('.container_wrap_first');
    });
    })(jQuery);
    });
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_category_banner');

    Please copy the code from the forum and not from an email notification so the symbols are copied correctly.
    Then add this css to your child theme stylesheet or the theme option Quick CSS:

    .avia-section.cat-banner {
    	height: 283px;
    	color: #fff;
        background-color: #f7f4ef;
        background-image: url(https://jean-michel-cosson.fr/wp-content/uploads/2022/10/blog-articles-par-jean-michel-cosson-3.jpg);
        background-repeat: no-repeat;
        background-position: 50% 50%;
        background-attachment: scroll;
    }
    .avia-section.cat-banner h1 {
      margin: 0;
      position: absolute;
      top: 36%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 1;
    }
    
    .avia-section.cat-banner .av-section-color-overlay {
        opacity: 0.4;
        background-color: #2b2b2b;
        height: 283px;
    }
    #top.archive.category .category-term-description {
    	display: none;
    }

    This is the expected results:
    2022-11-03_001.png

    Best regards,
    Mike

    #1371352

    Hi Mike,

    I tried the code. It works but since I have a problem on the home page ! The photo in the background jumps when you arrive on the site ! It didn’t do it before… I deleted the code added in function but the problem persists on the home page… Did you touch anything that would have caused this problem ? can you help me to solve it please?

    Thank you,

    Best regards,
    Audrey

    #1371374

    Hi,
    I didn’t make any changes to your site, the login you posted is not an admin login so I’m unable to see or modify any theme setting or WordPress settings, I didn’t even look at your homepage. From what I can see, from the Dev Tools, is the height of the element is changed from the 100vh (951px) which is the setting in the element, to 738px, but I can’t tell if it is custom css or a custom script.
    Try disabling your custom css and any scripts and your plugins, if this doesn’t help upgrade the login you post to admin so we can investigate.

    Best regards,
    Mike

    #1371432

    Hi Mike,

    Ok I’m sorry, I was just wondering where the problem could come from. I couldn’t solve the problem on the home page. I changed the role to administrator, could you help me solve the problem please ?

    Thank you very much, I really appreciate your help,

    Best regards

    #1371439

    Hi,
    Thanks for the login, I don’t know where this is coming from but I added this css to correct and it seems to be working:

    #top.home #av_section_1 {
    	height: 85.78vh;
    }

    please clear your browser cache and check.

    Best regards,
    Mike

    #1371454

    Hi Mike,

    YES ! it works ! Thank you very much !!
    One last question please : On the blog page, posts display in 2 columns on screens smaller than 989px. Is it possible to do the same for blog categories?

    Thank’s again, have a good day

    Audrey

    #1371472

    Hi,
    Glad to hear to make the category archive columns two wide for tablet try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function custom_archive_category_article_width() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
    (function($){
      $('#top.archive.category .slide-entry-wrap').each(function() {
      	var width = $(window).width();
      if ((width <= 989)) {
      	$('.slide-entry').removeClass('av_one_third').addClass('av_one_half');
      } else {}
    });
    })(jQuery);
    });
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_archive_category_article_width');

    the expected results:
    2022-11-05_002.png

    Best regards,
    Mike

    #1371508

    Hi Mike,

    Thank you for the solution you offer. Unfortunately, the page must be reloaded so that the columns are displayed in 2 columns, this is not done automatically when resizing the window. I found another solution: I put the blog in 2 columns whatever the size of the screen. In archive.php I changed the default column number.

    So problem solved ! Thank you very much for your help,
    Have a nice day

    Audrey

    #1371510

    Hi,
    Glad to hear that you have this sorted out, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Add the same banner as on the blog page, on the category page’ is closed to new replies.