Support » Fixing WordPress » [Plugin: Latest Custom Post Type Updates] Add date?

  • Resolved hahvensa

    (@hahvensa)


    Is it possible to add date to the latest custom post types widget. Now it only shows the post title if I’m correct.

    I guess it should be added somewhere here in the index.php

    // Get the posts!
            $posts = get_posts($params);
            // Print 'em out!
            if($posts)
                foreach($posts as $post)
                    echo '<li><a href="'.get_permalink($post->ID).'" title="'.$post->post_title.'">'.$post->post_title.'</a></li>';
            else {
                if($instance['empty_display'])
                echo '<li>'.$instance['empty_display'].'</li>';
            }
            // Always remember your closing tags!
            echo '</ul>'.$after_widget;
        }

    http://wordpress.org/extend/plugins/latest-custom-post-type-updates/

Viewing 6 replies - 1 through 6 (of 6 total)
  • A modified version might look like so:

    // Get the posts!
            $posts = get_posts($params);
            // Print 'em out!
            if($posts)
                foreach($posts as $post)
                    echo '<li>
                        <a href="'.get_permalink($post->ID).'" title="'.$post->post_title.'">'.$post->post_title.'</a><br />
                        <span class="date">'.get_the_date().'</span>
                    </li>';
            else {
                if($instance['empty_display'])
                echo '<li>'.$instance['empty_display'].'</li>';
            }
            // Always remember your closing tags!
            echo '</ul>'.$after_widget;
        }

    Alternatively, you might swap get_the_date() with get_the_modified_date() if you want the most recent edit date instead of the post publish date.

    OK, great! Just what I was looking for.

    Hi!
    Another question. I was wondering if it’s possible to display only today’s posts instead of the latest post? This plugin seems nice and simple and I thought maybe it’s easilly modified for that purpose 🙂

    It’s possible, but maybe not with this plugin. LCPTU uses the get_posts() command, and it looks like you can only do date queries with query_posts() (though I have not tested this).

    Try searching for “get today’s posts” and you’ll see what I mean!

    Thanks for your answer! Yeah that seems to be the problem. Maybe I find a way to do it with Query Posts plugin. But anyways, you have a great plugin! I just have a complex need.

    David Wood

    (@technical_mastermind)

    The plugin has been updated and now uses the WP_Query class to query posts. As such the ability to show the published date or the modified date in the widget now exists.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Latest Custom Post Type Updates] Add date?’ is closed to new replies.