The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] How to track changes to a post (post updates)? (5 posts)

  1. 5280angel
    Posted 9 years ago #

    Can someone help me figure out how to track changes I make to an already-published post? So I want to update an old post, and I want the change to be reflected in my "recent posts" section in the sidebar as if I had just published a new post.

  2. Kafkaesqui

    Posted 9 years ago #

    It all depends on what you're using to display your "recent posts."

    If it's a custom SQL query, the sort orderby column it's using can be changed to post_modified, rather than post_date (which it most likely does).

    If it's an internal query function like query_posts() or get_posts(), then passing it an orderby parameter value ('modified' for the former, 'post_modified' for the latter) would do.

    And if it's a plugin... the above applies, but of course we're talking about edits to the plugin's source.

  3. 5280angel
    Posted 9 years ago #

    Thanks for replying. I am using a plugin, and in the widgets.php file I have this section for the recent entries:


    function widget_recent_entries($args) {
    $title = __('Recent Posts', 'widgets');
    $r = new WP_Query('showposts=5');
    if ($r->have_posts()) :
    <?php echo $before_widget; ?>
    <?php echo $before_title . $title . $after_title; ?>

    <?php echo $after_widget; ?>

    what can i change in this section to show changes I make to old posts?

  4. Kafkaesqui

    Posted 9 years ago #

    Ah, the solution is an easy one. WP_Query() takes the same parameters as query_posts(), so this line in the plugin:

    $r = new WP_Query('showposts=5');

    can be changed to:

    $r = new WP_Query('showposts=5&orderby=modified');

    That will provide what you're after.

  5. 5280angel
    Posted 9 years ago #

    Thank you very much! That worked perfectly.

Topic Closed

This topic has been closed to new replies.

About this Topic