Support » Themes and Templates » Omit or change title post from $wp_query->current_post> 0

  • Resolved Hortensiagg



    I have change the content.php in my child theme so that it reflects on the home page a full top post and the rest to be thumbnails with title and excerpts.

    The problem is that I get two post titles in my thumbnails with excerpts

    this is what I have for a code:

    <?php if (is_search () || is_paged() || $wp_query->current_post> 0): // Only display excerpts for Posts and Search ?>
    <div class="entry-summary"></div>
    <!-- This adds the post thumbnail/featured image, title and excerpt-->
    <div class="excerpt-thumbpost">
    <h7 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute() ); ?>" rel="bookmark"><?php the_title(); ?></a></h7>
    <?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft' ) ?> </div> 
    <?php the_excerpt(); ?>

    I know that the problem is in the “$wp_query->current_post> 0” above. How can I omit the extra title with date? I want to keep the one that is on the side of the thumbnail……


Viewing 8 replies - 1 through 8 (of 8 total)
  • esmi


    Forum Moderator

    For a start, there’s no such HTML element as h7.



    Forum Moderator

    please post the full code of the template
    – please use the pastebin – see

    the title with date is possibly before and outside of your conditional section.

    Hi guys!

    I made my own custom h7 in css….

    This is the link to the code in the content.php file 🙂

    Thanks Again!



    Forum Moderator

    I made my own custom h7 in css

    That doesn’t matter. There’s still no h7 markup element. Perhaps you meant to use <span class="h7>...</span>?



    Forum Moderator

    you have the title code in line 20 of the pastebin, and this will get shown regardless of the $wp_query->current_post value;
    (it will also show the date due to lines 23 to 27)

    then you show another title with the code in line 41 when $wp_query->current_post is greater than the first post.

    possibly wrap line 13 to 34 into a conditional statement to show them only for the first post;
    i.e. add this before line 13:
    <?php if( $wp_query->current_post == 0 ) : ?>
    and add this after line 34:
    <?php endif; ?>

    Hi Alchymyth!

    This works great!

    But now, the only problem left is that I have set the post pages to show 3 per page, in the principal page, this code works wonders, but when I go to the next page, my first excerpt shows the two titles (I guess since it the first post):

    How do you think this can be solve? 🙂



    Forum Moderator

    I forgot to add the ‘is_paged()’ into the new condition:

    change this (from my latest reply):

    <?php if( $wp_query->current_post == 0 ) : ?>


    <?php if( $wp_query->current_post == 0 && !is_paged() ) : ?>

    It works! It works!
    Thanks alot Alchymyth!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Omit or change title post from $wp_query->current_post> 0’ is closed to new replies.