WordPress.org

Forums

[resolved] Show Categories on Sidebar (5 posts)

  1. noelgreen
    Member
    Posted 7 years ago #

    I have a site that I want to show the excerpt from the recent post in 2 categories in the sidebar. It works on the main page, but other pages it comes up blank.

    Here's the code...

    <?php query_posts('cat=4,5'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php the_excerpt(); ?>
    <?php endwhile; endif; ?>

    Suggestions, ideas?

  2. noelgreen
    Member
    Posted 7 years ago #

    I see a LOT of posts on here that are close to solving this, but nothing I've found yet solves it.

  3. noelgreen
    Member
    Posted 7 years ago #

    This almost does it.

    <?php $postlist = get_posts('category=4');
    foreach ($postlist as $post) :?><a href="<?php the_permalink() ?>" rel="bookmark" title="Buy this..."><?php post_image('default_image', 'use_thumb=1'); ?></a><?php endforeach; ?>

    But the problem is I'm actually not just trying to post the excerpt... I'm using the Post Image plug-in and that's not allowing me to use it there.

    So... any suggestions on this?

  4. noelgreen
    Member
    Posted 7 years ago #

    Any help?
    Pretty please with code on top?

  5. noelgreen
    Member
    Posted 7 years ago #

    Got it!!!

    This code works:

    <?php query_posts('cat=4'); ?>
    <?php $posts = get_posts('category=4&offset=0');
    foreach ($posts as $post) : start_wp(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Buy this..."><?php post_image('default_image', 'use_thumb=1'); ?></a>
    <?php endforeach; ?>

    I found it here.

Topic Closed

This topic has been closed to new replies.

About this Topic