• Resolved goldmember

    (@goldmember)


    i have two categories of post that i make, Previous Events and Upcoming Events.

    i put the “Recent Posts” widget in my Main Sidebar and titled it “Upcoming Events”. The problem is i can only set it to list the 5 most recent posts. I can’t get it to be more specific so that it only lists the 5 most recent “Upcoming Events”.

    ideally, I’d like to have one widget list the most recent five “Upcoming Events” and one widget list the most recent five “Previous Events.

    is there anyway to do this? please advise. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Could use this in a PHP Code Widget:

    <?php
    //display 5 posts for category ID 12
    $taxonomy = 'category';
    $taxargs ='include=12';
    $terms = get_terms( $taxonomy, $taxargs );
    foreach( $terms as $term )  {
      $args=array(
        'category__in' => array($term->term_id),
        'showposts'=> 5,
        'caller_get_posts'=>1
       );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        echo '<h2>Posts from '. $term->name . '</h2>';
        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().
    } //foreach
    ?>

    Thread Starter goldmember

    (@goldmember)

    thanks. but what do you mean “in”? where do i put this code?

    Thread Starter goldmember

    (@goldmember)

    thanks. but what do you mean “in”? where do i put this code?

    Consider downloading and installing Otto’s PHP Code Widget.

    Then put the code in one those widgets.

    Thread Starter goldmember

    (@goldmember)

    thanks. so i have the widget installed and the “Previous Events” heading correctly appears in my lefthand nav bar where I want it. And i dropped the php code that you detailed above into the widget. however nothing appears. how do i tell it what i want to list?

    btw, i know little to nothing about the inner workings of php so bear with me. thanks!

    Change this to be the category of your previous or upcoming events:
    $taxargs =’include=12′;

    Thread Starter goldmember

    (@goldmember)

    got it. thanks!!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘multiple recent post widgets’ is closed to new replies.