WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] I want to show the most recent post from a certain category always at the top (5 posts)

  1. Skeary
    Member
    Posted 6 years ago #

    I'm working on getting a new site up and running here

    I want the top post to always be the most recent post from the 'playlists' category.

    Alternatively/also (depending) I would like to show the most recent playlist post separately in a slightly different formatted box at the top of the page, and then have the rest of the posts below as normal.

    any ideas as to how would be the best way? I've seen a few plug-ins that did vaguely similar things but many of them weren't compatible with the newest version of wp..

    thanks!

  2. moshu
    Member
    Posted 6 years ago #

    3 custom loops: The_Loop

  3. Skeary
    Member
    Posted 6 years ago #

    vague, but potentially useful.. will investigate further.. ;)

  4. Skeary
    Member
    Posted 6 years ago #

    I'm having some trouble with this...
    I'm trying to use the example they provide on the bottom of the loop page (which is just about exactly what I want to do..) however when I include the last query they give as the example it causes an 'unexpected $end' on the last line of index.php.

    now if i understand correctly the basic structure of the page should look like (i'm editing index.php of the sandbox theme):

    <?php $my_query = new WP_Query('cat=1&showposts=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID; ?>
    
    <!--theme stuff, from original index.php with added header--!>
    
    <?php endwhile ?>
    		</div><!-- #content -->
    	</div><!-- #container -->
    <?php rewind_posts(); ?>
    <?php query_posts; ?>
    <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
    <!--theme stuff repeated from original index.php--!>
    <?php endwhile ?>
    
    	<div id="nav-below" class="navigation">
    	<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&laquo;</span> Older posts', 'sandbox')) ?></div>
    	<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">&raquo;</span>', 'sandbox')) ?></div>
    			</div>
    		</div>
    	</div>
    <?php get_sidebar() ?>
    <?php get_footer() ?>

    any idea how to make this work right??

  5. Skeary
    Member
    Posted 6 years ago #

    i got it fixed up using example from here

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.