WordPress.org

Ready to get started?Download WordPress

Forums

Displaying only posts with a modified date/time (1 post)

  1. Lassirra
    Member
    Posted 3 years ago #

    I'm not sure if this is the right place to post this or not, but here goes.

    I'm putting some extra code into my sidebar.php file (in addition to the dynamic widget code) so that I can include a couple specific sections in the sidebar without having to manually maintain widgets for them in the dashboard. One of the sections queries and displays the most recent posts of a specific custom post type. That part works fine. Here's the part I'm having trouble with:

    In the second section, I want to query the most recent posts of that same custom post type that have been modified.

    So, for the first section (the most recent posts, which works) I have this:

    <div class="widget">
    	<h3 class="widgettitle">Latest Guides</h3>
    
    	<ul>
    
    		<?php $args=array('post_type'=>'guide', 'showposts' => 5);
    					$my_query = new WP_Query($args);
    							while ($my_query->have_posts()) : $my_query->the_post();
    
    		$do_not_duplicate = $post->ID; ?>
    
    		<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> <span class="post-updated">(<?php the_time('d.m.Y') ?>)</span></li>
    						<?php endwhile;?>
    
    	</ul>
    </div>

    I want to use the same sort of query (if possible) for the second section to get the most recent guides that have a the_modified_time() that is different from the_time(), so that the second widget isn't just displaying the same posts as the first one if the modified date/time of the posts is the same as the publish date/time.

    I've tried using an if statement to accomplish this
    if (the_modified_time() != the_time()) {
    but that didn't work, so I'm not sure how I might accomplish this.

    I've searched google and the support forums here and haven't been able to find anything that addresses this, so any help anyone might provide would be appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic