Support » Fixing WordPress » Otto's recent custom post types in sidebar

  • Resolved Roy


    I wanted to display the last five titles of custom post types in the sidebar. I ran into Otto’s almost perfect sollution. The only thing with this is, is that whereas all my widgets have just five lines with links, Otto’s code makes a list of five with a blank line between them. Can this be solved in the code?

Viewing 3 replies - 1 through 3 (of 3 total)
  • No luck with trial-and-error. Anybody with real insight have a thought?

    I just noticed that it is actually Michael’s almost perfect sollution. Sorry Michael 🙂

    Yesss, my eye just fell on a <p> </p> that apparently isn’t needed. I now use the code:

      'post_type' => 'blog',
      'post_status' => 'publish',
      'posts_per_page' => 5,
      '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(); ?>
        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    wp_reset_query();  // Restore global post data stomped by the_post().

    That’s a blank line between the widget title and the post titles, but that’s something in my theme I can’t figure out. I have the same with other widgets.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Otto's recent custom post types in sidebar’ is closed to new replies.