• Hey all

    I couldn’t find this topic anywhere, so excuse me if it’s already been asked.

    I am trying to change my blog page so that only the latest/top post shows full content, the featured image and the comment box, and for the rest of the entries below it to show just their titles without any content snippets.

    Is there a way to set it up so I can edit the code for just the latest post, and then I will just edit the main loop to only show the titles for the rest of the posts?

    My first instinct was “first-child” but that more pertains to css styling, not really what i’m trying to achieve.

    Am I on the right track?

    Site is here: perspectiveinaction.com

    Thanks in advance

Viewing 14 replies - 1 through 14 (of 14 total)
  • Hi,

    You seem to have a good knowledge of PHP. There are many ways to do this but one I could think of is that you should have 2 loops one limited to show only one post which is your latest post and the other one to only show the Titles.

    Have a look at this: Query Posts

    If you need I could have a look at your code and help you more to achieve this goal.

    Edsoltani, do not provide posters with your email.

    respectyoda: thanks for the judgment but I think a poster is when you make profit, I’m offering to help for free. Why not you try to help some others for free instead of complaining about others gratitude ??

    You need to understand the rules of this forum. Please read this. It specifically says:

    Forum members should not post their email addresses, ask others to post their email or solicit contacting people off of the forums.

    Thanks for the reminder, if you see I have already deleted the email address. Hope I haven’t done any harm to your business ??

    Thread Starter Jessi

    (@wbjtk)

    edsoltani, thank you for your help!!

    I didn’t think I knew too much about php, but i think i could tackle this!! i’m going to give it a try and if i run into trouble, maybe you could see what im doing wrong – thanks!!

    You are welcome, it should be fun to figure it out and I hope you do. I would be glad to help with any further questions.

    Thread Starter Jessi

    (@wbjtk)

    Ok so everything is there, except for the second loop, it’s only giving me the latest post again. Do I have to reset the query or something?

    <?php query_posts('posts_per_page=1'); ?>
    				<?php if ( have_posts() ) : ?>
    					<?php while ( have_posts() ) : the_post(); ?>
    						<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<header class="entry-header">
    		<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    		<?php dw_minion_entry_meta(); ?>
    	</header>
    	<?php if( has_post_thumbnail() ) : ?>
    	<div class="entry-thumbnail"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a></div>
    	<?php endif; ?>
    	<div class="entry-content">
    		<?php the_content(); ?>
    	</div>
    </article>
    <?php comments_template(); ?>
    <?php endwhile; ?>
    				<?php else : ?>
    					<?php get_template_part( 'no-results', 'index' ); ?>
    				<?php endif; ?>
    
    				<?php if ( have_posts() ) : ?>
    					<?php while ( have_posts() ) : the_post(); ?>
    						<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<header class="entry-header">
    		<h2 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    		<?php dw_minion_entry_meta(); ?>
    	</header>
    </article>
    <?php endwhile; ?>
    				<?php else : ?>
    					<?php get_template_part( 'no-results', 'index' ); ?>
    				<?php endif; ?>

    Sorry I have Updated my post try this, this shows title and content for the latest post and titles of next 10 posts.

    <?php
    // The Query
    query_posts( 'posts_per_page=1' );
    
    // The Loop
    while ( have_posts() ) : the_post();
    	the_title();
        the_content();
    endwhile;
    
    query_posts( 'posts_per_page=10' );
    // The Loop
    while ( have_posts() ) : the_post();
        echo '<li>';
        the_title();
        echo '</li>';
    endwhile;
    
    ?>

    Thread Starter Jessi

    (@wbjtk)

    Woohoo there it is!

    Not only have you solved my issue, but you’ve taught me something along the way!! =) thank you so much for your help

    I’m glad I helped. You are most welcome.

    Thread Starter Jessi

    (@wbjtk)

    any clue how to omit the last post from the second query? it is shown again (not sure if we can avoid this using this method)

    Thread Starter Jessi

    (@wbjtk)

    solved that myself lol

    on the second loop, add the offset=1. This query is telling the loop to only display 5 posts which follow the most recent post (1).

    <?php query_posts('posts_per_page=10&offset=1'); ?>

    Great! You knew what you were doing, so I’m not surprised. Good Luck with the rest.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Unique latest post’ is closed to new replies.