• Resolved paddyinthesun

    (@easylifespain)


    Recently, i have found out how to remove meta-data from a static post by using the following code (kindly provided by esmi here) in the loop (loop.php) :

    <?php if( !is_sticky() || !is_home() ) :?>
    <div class="entry-utility">
    [...]
    </div><!-- .entry-utility -->
    <?php endif;?>

    I’m not sure how this code works as i am now trying to remove the cat-links, meta-sep, comments-link and edit-link contained in the entry-utility and i can’t figure it out.

    Hope that is clear, can anyone help or point me in the right direction.
    First post is sticky https://www.mijasguide.com/

Viewing 10 replies - 1 through 10 (of 10 total)
  • <?php if( !is_sticky() || !is_home() ) :?> = if this post is not sticky or if this post is not on the home (main posts) page.

    ! = not and || = “or” in PHP.

    You need to place the first line <?php if( !is_sticky() || !is_home() ) :?> immediately before div class="entry-utility"> and the last line <?php endif;?> immediately after ?php endif;?> in loop.php near the bottom of the file.

    Thread Starter paddyinthesun

    (@easylifespain)

    Hi esmi,
    Thanks for helping me again. In loop.php i have 3 instances of div class="entry-utility">
    When i place the line <?php if( !is_sticky() || !is_home() ) :?> before the 1st or 2nd instance, no posts appear. If i place it before the 3rd instance, the meta data appears as its outside that loop.
    I’ve left it after the 3rd instance, can you see where i am getting muddled?
    wwww.mijasguide.com

    Drop a copy of loop.php into the WordPress pastebin and post the pastebin url here.

    Thread Starter paddyinthesun

    (@easylifespain)

    https://wordpress.pastebin.com/3qLceMy4
    The current loop.php is stopping my sidebar from appearing on the home page too.

    Thread Starter paddyinthesun

    (@easylifespain)

    I’ve moved my <?php endif;?> to wher you have and i now have my sidebar back but the entry-meta is still showing.
    Can i get the meta-data into that loop to stop it from appearing in the sticky post??

    Are you sure that the post is sticky and that this is your main posts page?

    Thread Starter paddyinthesun

    (@easylifespain)

    Yep, the post is definitely sticky and its my main post page.

    I have solved it by adding the same if/endif aroud the entry-meta

    <?php if( !is_sticky() || !is_home() ) :?>
    <?php endif;?>

    Not sure if this is good coding practice.

    It’s perfectly good coding practice. ??

    Thread Starter paddyinthesun

    (@easylifespain)

    Excellent, thank you very much.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Remove entry-utility from sticky post’ is closed to new replies.