• Resolved ozzie123

    (@ozzie123)


    Hello guys,

    I know that we can use:

    <?php wp_get_archives(‘type=postbypost&limit=15’); ?>

    to ‘retracts’ 15 latest post out of all categories. But is it possible for me just to include latest post from CERTAIN categories?

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter ozzie123

    (@ozzie123)

    Oh plus, what I mean by including latest post doesn’t mean the entire post. What I meant is just including the title of the latest post on certain categories.

    I’ve found this link: http://wordpress.org/support/topic.php?id=21194 but that didn’t help me much.

    Thread Starter ozzie123

    (@ozzie123)

    Hello, anybody?

    You could use something like this (I got it here in the forum somewhere:)
    <?php $temp_query = $wp_query; ?>
    <?php query_posts('cat=X&showposts=5'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <h5 id="post-<?php the_ID(); ?>">
    <?php the_title(); ?></h5>
    <span class="show"><?php the_content(); ?></span>
    <?php endwhile; ?>
    <?php $wp_query = $temp_query; ?>

    just replace the cat=X part with the ID# of your category; and change the showposts number to how many posts you want to display…
    …and of course edit the id, span etc. – I copied from a sidebar I was testing on my local install.

    Thread Starter ozzie123

    (@ozzie123)

    moshu, that really works! Thanks.

    But somehow it seems that I have a problem on making the title “clickable”. Do you know how can I make the title linkable so that everytime a person clicks, it goes right into the appropriate entry?

    Thanks

    Try replacing <?php the_title(); ?> with
    <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>

    Thanks IanD, I just copied the code from my test site as it was, without thinking what did I modify for my needs…

    Thread Starter ozzie123

    (@ozzie123)

    Thanks IanD! It worked!

    hey guys, that’s a good solution of course…but what should I put instead of ID# to get the actual category!? the one I’m in at the moment?
    hope u understand what I mean, thanks n regards

    Andrea

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Listing Post on certain category on sidebar’ is closed to new replies.