WordPress.org

Ready to get started?Download WordPress

Forums

DIsplay Single at Category ? (6 posts)

  1. thornomad
    Member
    Posted 8 years ago #

    Hi,

    When I click on a category link, instead of getting the most recent posts generated in that category, I would rather be brought to THE most recent post (and that is all).

    I can do this by limiting the loop to only displaying the FIRST post, but what I would rather do, is have some kind of fowarding mechanism that when category-1 is called, it will instead bring me to the single of the latest post in that category (so I can use the next_post and previous_post links).

    Any ideas ?

  2. Chris_K
    Member
    Posted 8 years ago #

    I haven't a clue how to get exactly where you're headed, but I have a thought.

    Start with this plugin: http://mattread.com/projects/wp-plugins/custom-query-string-plugin/

    It will let you set your assorted category queries to 1 without changing how other parts of your blog are listed. Perhaps then you could just customize your category.php to have the next / prev links and display full post.

  3. thornomad
    Member
    Posted 8 years ago #

    I will check it out: what I would like to be able to do is just use:

    <?php query_posts('cat=1&showposts=1');
    while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="">What's New</a></li>
    <?php endwhile; ?>

    This accomplishes what I want, however, it messes up my loop and I don't know how to reset the loop to work right.

    D

  4. Chris_K
    Member
    Posted 8 years ago #

    While template file's loop is that you're editing?

  5. dss
    Member
    Posted 8 years ago #

    I was just working on this.

    I think this code may help you:


    <? // the first loop ?>
    <?php if (have_posts()) : ?>
    <?php query_posts('cat=4&amp;showposts=1');
    while (have_posts()) : the_post(); ?>

    <div class=&quot;post&quot; id=&quot;post-<?php the_ID(); ?>&quot;>
    <h2><a href=&quot;<?php the_permalink() ?>&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to <?php the_title(); ?>&quot;><?php the_title(); ?></a></h2>

    <div class=&quot;entry&quot;>
    <?php the_excerpt('Read More &amp;raquo;'); ?>
    </div>
    </div>

    <?php endwhile; ?>
    <? // End the first loop ?>

    <? // The second loop ?>

    <?php rewind_posts(); ?>

    <?php query_posts('cat=1&amp;showposts=1');
    while (have_posts()) : the_post(); ?>

    <div class=&quot;post&quot; id=&quot;post-<?php the_ID(); ?>&quot;>
    <h2><a href=&quot;<?php the_permalink() ?>&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to <?php the_title(); ?>&quot;><?php the_title(); ?></a></h2>

    <div class=&quot;entry&quot;>
    <?php the_excerpt('Read More &amp;raquo;'); ?>
    </div>
    </div>

    <?php endwhile; ?>

    <? // End the second loop ?>

    Hope this helps.

  6. dss
    Member
    Posted 8 years ago #

    Well... that didn't decode so well did it?

    the &quot; are supposed to be quotations

    Hopefully you can work it out.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.