Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1395177
    davidferp
    Participant

    Hi X-ers!,

    The posts of my blog are designed to include a featured image at the top before the post title, and the site menu overlays the featured image in single post view (see ‘with features image.png’ attached).

    However, when no featured image is defined, the site menu appears directly above the post title, which is not the intended effect I am searching for (see ‘without features image.png’ attached).

    In posts without featured image defined I want to apply enough top padding to avoid the post title to appear underneath the site menu. I guess the solution combines PHP and CSS but I cannot seem to solve the problem.

    Any thoughts?

    Thanks a lot guys for your very much appreciated help

    Regards,

    #1395194
    Thai
    Moderator

    Hi There,

    Please provide us with your website URL so we can take a closer look.

    Thanks.

    #1395270
    davidferp
    Participant

    Sure thing, here you go: http://www.2cameras1bucketlist.com

    #1395693
    Paul R
    Moderator

    Hi,

    To fix it, add the code below in your child theme’s functions.php

    
    add_action('body_class', 'ed_if_featured_image_class' );
    function ed_if_featured_image_class($classes) {
     if ( has_post_thumbnail() && is_singular('post')) {
          array_push($classes, 'has-featured-image');
     }
     return $classes;
    }
    

    Then change the code in your custom css that reads.

    
    @media (min-width: 980px) {
    	.single-post .x-main.full {
    	    margin-top: -171px;
    	}
    }
    

    with this

    
    @media (min-width: 980px) {
    	.single-post.has-featured-image .x-main.full {
    	    margin-top: -171px;
    	}
    }
    

    Hope that helps.

    #1396254
    davidferp
    Participant

    Hello there,

    I certainly helps! Thanks a lot!

    #1396317
    Joao
    Moderator

    Glad to hear it,

    Cheers

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