Forums

Looking for plugin that will publish posts from one category in the sidebar (2 posts)

  1. Mikion
    Member
    Posted 2 years ago #

    Hello, there is plenty of plugins and I can not find any plugin that is able to publish posts from one category in the sidebar.

    I want to make something as second small blog on my website (the posts will be published in the sidebar).

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    You could use http://wordpress.org/extend/plugins/query-posts/ to do that.

    Or put this in your sidebar.php or in a PHP Code Widget

    <?php
        $args=array(
          'cat' => 7,
          'showposts'=>5,
          'caller_get_posts'=>1
        );
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo '5 recent Posts in category 7';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
          endwhile;
        } //if ($my_query)
      wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.