Support » Fixing WordPress » [Plugin: Events Category] Works but inteferes with other dates in loop

  • Mike

    (@shakingpaper)


    Hi,

    I am using this widget on a page that prints out (in list form) the most recent items for a few categories (there is a news list and an events list)

    When I added the event category code to my loop, it made the date for my news links dissapear.

    The code is below:

    <?php
    	    global $post;
    	    $the_newest = get_posts('cat=4&amp;showposts=2');
    	    $the_newer = get_posts('cat=3&amp;showposts=2');
    	?>
    
    		<ul id="events">
    			<?php foreach($the_newest as $post) :
      			setup_postdata($post);  ?>
    			<li class="news_post_1" id="post-<?php the_ID(); ?>">
    			<h2><a href="<?php echo get_permalink(); ?>"><?php if (strlen($post->post_title) > 25) { echo substr(the_title($before = '', $after = '', FALSE), 0, 25) . '...';} else {the_title();} ?></a></h2>
    			<p><?php eventscategory_get_the_time('l j F, Y') ?> | <a href="<?php echo get_permalink(); ?>">More...</a></p>
    			</li>
    			<?php endforeach; ?>
    		</ul>
    
    		<ul id="news">
    			<?php foreach($the_newer as $post) :
    			setup_postdata($post);  ?>
    			<li class="news_post_1" id="post-<?php the_ID(); ?>">
    			<h2><a href="<?php echo get_permalink(); ?>"><?php if (strlen($post->post_title) > 25) { echo substr(the_title($before = '', $after = '', FALSE), 0, 25) . '...';} else {the_title();} ?></a></h2>
    			<p><?php the_date('l j F, Y') ?> | <a href="<?php echo get_permalink(); ?>">More...</a></p>
    			</li>
    			<?php endforeach; ?>
    		</ul>

    Any help would be great as the plugin is perfect for my needs,
    Thanks,

    Michael

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Mike

    (@shakingpaper)

    Anyone able to help out with this?

    Hello Michael,

    Try something like this:

    ` <?php
    $my_query = new WP_Query(‘category_name=featured&showposts=1’);
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    <!– Do stuff… –>
    <?php endwhile; ?>
    `
    Do please let me know if that worked,

    Best,
    Linda

    Hi again,

    the idea is to substitute your call to get_posts by WP_query …

    Cheers,
    Linda

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Events Category] Works but inteferes with other dates in loop’ is closed to new replies.