• I want to have a link to a page in a sidebar but have it show an excerpt. I’m not sure if I should use the list pages thing or query posts. Any suggestions? Is there some easy way to perform this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You probably need to have something like this in the sidebar:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <div class="whateveryouwant">
    <?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    </div>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>

    or maybe just

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="whateveryouwant">
    <?php the_excerpt('Read the rest of this entry &raquo;'); ?>
    </div>
    <?php endwhile; ?>
    <?php endif; ?>

    p.s that would (maybe) turn your sidebar into sort of a blog homepage.

    Anyway, I have to hang it up for the night.

    Thread Starter estevancarlos

    (@estevancarlos)

    Thanks for the push in a clearer direction. The only catch is I want it to load an excerpt of a specific page. I’m actually using this now:

    <?php global $post; $myposts = get_posts('numberposts=1&post_type=page&name=about'); ?>

    After that I have some code to show an excerpt. However the “name=about” does not work. When I remove the name part, it’s fine. I don’t understand that component. I just need it to load one specific page.

    How about using ‘pagename’ instead of ‘name’?

    http://codex.wordpress.org/Template_Tags/query_posts#Post_.26_Page_Parameters

    Thread Starter estevancarlos

    (@estevancarlos)

    Actually, also, this excerpt thing isn’t really working properly. I want an excerpt in a sidebar. I want only an excerpt in all instances. For some reason, if you click on an unrelated post in the main area, it will reload the sidebar and show the entire content in the sidebar instead of the excerpt. I would assume the content only shows when you click on the specific item to read it. I don’t follow why it would show the full content even when I’m reading something else.

    Thread Starter estevancarlos

    (@estevancarlos)

    Yeah, I later noticed my mistake but I’m using get_posts instead of query_posts.

    I was just going to send you the same link that @nouveller already posted.

    Thread Starter estevancarlos

    (@estevancarlos)

    to my understanding “get_posts” doesn’t support pagename:

    http://codex.wordpress.org/Template_Tags/get_posts

    and I used “name” incorrectly earlier. that was for ordering.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How might I list an excerpt of a Page?’ is closed to new replies.