WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Omit or change title post from $wp_query->current_post> 0 (9 posts)

  1. Hortensiagg
    Member
    Posted 1 year ago #

    Hello!

    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 http://www.ecobitat.com

    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......

    Thanks!

  2. esmi
    Forum Moderator
    Posted 1 year ago #

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

  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    please post the full code of the template
    - please use the pastebin - see http://codex.wordpress.org/Forum_Welcome#Posting_Code

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

  4. Hortensiagg
    Member
    Posted 1 year ago #

    Hi guys!

    Esmi
    I made my own custom h7 in css....

    Alchymyth
    This is the link to the code in the content.php file :)
    http://pastebin.com/XuwWAGNd

    Thanks Again!

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    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>?

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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; ?>

  7. Hortensiagg
    Member
    Posted 1 year ago #

    Hi Alchymyth!

    This works great!
    Thanks.

    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):

    http://www.ecobitat.com/page/2

    How do you think this can be solve? :)

  8. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

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

    change this (from my latest reply):

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

    to:

    <?php if( $wp_query->current_post == 0 && !is_paged() ) : ?>
  9. Hortensiagg
    Member
    Posted 1 year ago #

    It works! It works!
    Thanks alot Alchymyth!

Topic Closed

This topic has been closed to new replies.

About this Topic