Forums

ignore unmodified post (17 posts)

  1. gbaka
    Member
    Posted 2 years ago #

    I'm using the query_post modified code to display modified post I'm just wondering is there a way to ignore or hide unmodified post?

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    Something like this in a 'normal' loop:

    if ($post->post_date != $post->post_modified) {
    //display your modified posts
    }

    [edit]

  3. gbaka
    Member
    Posted 2 years ago #

    well it works for the most part except i can't control the amount of post that show up in the page because it seems to be counting non editted post as well any to control that show ignores the noneditted post from the post count?

  4. MichaelH
    Volunteer
    Posted 2 years ago #

    That would be true. To make pagination work, you'd have to do something like this:

    <?php
      function filter_where($where = '') {
        $where .= " AND post_date != post_modified ";
        return $where;
      }
    add_filter('posts_where', 'filter_where');
    query_posts($query_string);
    ?>

    Didn't test this though. May need a remove_filter also.

  5. gbaka
    Member
    Posted 2 years ago #

    this seems to only show updated post that are still on the frontpage and doesn't show any updated post that aren't on the front page.

  6. MichaelH
    Volunteer
    Posted 2 years ago #

    May need to put remove_filter('posts_where', 'filter_where'); after the query.

  7. gbaka
    Member
    Posted 2 years ago #

    okay it didn't change it, all the modified post seem to go by the original date and not the modified date and its messing up the updated order. So older post don't show up on the modified page.

  8. MichaelH
    Volunteer
    Posted 2 years ago #

    Just so I can test this, what template (e.g. index.php, archives.php} are you putting the code in and where are you seeing the problem? I'll be using the WordPress Default theme.

  9. gbaka
    Member
    Posted 2 years ago #

    I'm putting it in the index code and I'm seeing the problem in the order it doesn't seem to be in modified order.

  10. MichaelH
    Volunteer
    Posted 2 years ago #

    Works okay for me--note that sticky posts will be included.

    The SQL that generates is this:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND post_date != post_modified ORDER BY wp_posts.post_date DESC LIMIT 0, 5

  11. gbaka
    Member
    Posted 2 years ago #

    it works but it won't stick post that aren't already showing on the first page to the first post updated on the modified page. So they don't really update in order they update but the newest update doesn't go to the top of the page so the order for the modified page is post added and not post modified order.

  12. MichaelH
    Volunteer
    Posted 2 years ago #

    Not too sure about that but maybe try the 'caller_get_posts'=>1 or 'caller_get_posts'=>0 argument with your query.

    Good Luck.

  13. gbaka
    Member
    Posted 2 years ago #

    sorry i just edited my post so its clearer the post order isn't using post modified order is what i meant.

  14. MichaelH
    Volunteer
    Posted 2 years ago #

    Okay well maybe someone else can jump in with a different solution.

  15. gbaka
    Member
    Posted 2 years ago #

    Recently Updated Posts plugin seems to do it properly but I'm not sure what part of the code does the order and I can't edit it well enough to fit my needs.

  16. MichaelH
    Volunteer
    Posted 2 years ago #

    This topic has another possibility but you would need to to change http://wordpress.org/support/topic/337645

    post_modified_gmt != post_date_gmt

    to

    post_modified_gmt = post_date_gmt
  17. gbaka
    Member
    Posted 2 years ago #

    I'm trying to get the post order so it is ordered by post_modified_gmt instead of post_date_gmt so I'm not sure how making them equal would do any good but than I only know the very basics of php, the link you gave me does seem to work but it seems alot more difficult to modify and all i need my current code to do is be able to go by modified order instead of the default order.

Topic Closed

This topic has been closed to new replies.

About this Topic