WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] sidebar posts (3 posts)

  1. carlos campo
    Member
    Posted 5 years ago #

    I am developing a theme with posts in the right sidebar under category 'SIDEBAR'. The sidebar posts show an image and a short desription followed by the <!--more--> insert.
    The main posts are under category 'CENTRE' and also use the <!--more--> insert.
    Unfortunately If I click to read a centre post, or sidebar post (single.php) the sidebar posts now display the complete contents.
    How can I stop this from happening

    main pages:
    <?php query_posts('category_name=centre');
    php if (have_posts()) : php while (have_posts()) : the_post(); ?>

    stuff here

    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    Sidebar:
    <?php query_posts('category_name=sidebar');
    php if (have_posts()) : php while (have_posts()) : the_post(); ?>

    stuff here

    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    Thanx

  2. stvwlf
    Member
    Posted 5 years ago #

    Hi

    I worked this out the other day

    using the more tag on a page or in the sidebar

    <?php
    global $more;
    $sidebar = new WP_Query();
    $sidebar->query('category_name=sidebar');
    while ($sidebar->have_posts()) : $sidebar->the_post();
       $more = false;   // set $more to false to only get the first part of the post ?>
       <p><?php the_content('Read the rest...'); ?></p>
    <?php endwhile;
    $more = true;   // restore default $more behavior
    ?>
  3. carlos campo
    Member
    Posted 5 years ago #

    Hey stvwlf,
    thanks for the prompt reply and thanks heaps the code above which works just great. I believe WP can do anything if one has the support of this forum.
    Again.. thanks
    Carlos

Topic Closed

This topic has been closed to new replies.

About this Topic