• Hello

    I’m creating a child theme for twenty ten and want to display an excerpt from the latest post in the sidebar with a link to the posts page.

    I’ve found a plugin called Simple Post Preview which does almost what I want, though you can only like to the rest of the post or the category. I want to link to the post page.

    I’ve only just started learning php.

    Any help would be much appreciated. Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I want to link to the post page.

    Do you mean the single post display?

    See Template Hierarchy

    Thread Starter wambamboo

    (@agatha1)

    I mean the page with all my blog posts on it (which is not my homepage).

    Clicking on a post title typically means WordPress will want to display that post using the single post template.

    If you don’t like that you will need to manufacture the link and not use the post permalink

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php bloginfo('url'); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      the_excerpt();
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter wambamboo

    (@agatha1)

    Ok you got me there. I think maybe I’m attempting something a little above my skill level at the moment.
    Thanks anyway.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display excerpt in sidebar’ is closed to new replies.