Sort listing by latest modified

This topic contains 2 replies, has 3 voices, and was last updated by  Giri 8 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #229333

    jotomas
    Buyer
    Post count: 802

    Hi,

    GD Listing shortcode has this option:

    list_sort – One of az, latest, featured, high_review, high_rating, random (default = latest)

    But I have found that “random” does not work well with pagination, as mentioned in this post: https://wpgeodirectory.com/support/topic/random-pagination-broken/

    Then, I would like to sort by the latest modified post, to incentivate my customers to update their posts adding infos, news, offers, promotions and so on.

    Is there some way to sort by latest modified posts? Perhaps using some plugin like the following ones?

    https://es.wordpress.org/plugins/post-updated-date/
    https://wordpress.org/plugins/silent-update/

    Thanks for your help.

    Best regards.

    J.O.

    #229546

    Paolo
    Site Admin
    Post count: 31211

    Hi,

    currently there is no option to modify the sorting by last modified. I doubt there is a plugin that will work that way with GD custom queries.

    I asked to the developers to let us know if there is any easy way to accomplish this via filters, but I can’t promise anything.

    They’ll let us know asap.

    Thanks

    #229677

    Giri
    Expired Member
    Post count: 3155

    Ok, Follow these steps to sort by last modified.

    Note: current code only works for listing pages.

    1) Geodirectory > Place Settings > Sort options > Make sure you have added “Date”

    2) Select descending should be checked and set as default should be selected too. For value enter “Last Modified”

    3) Save it

    4) Now paste the following code in your child theme’s functions.php file

    
    
    function last_modified_geodir_posts_order_by_sort($orderby, $sort_by) {
        if (($sort_by == 'post_date_desc') && geodir_is_page('listing')) {
            $orderby = str_replace('posts.post_date desc', 'posts.post_modified desc', $orderby);
        }
        return $orderby;
    }
    add_filter('geodir_posts_order_by_sort', 'last_modified_geodir_posts_order_by_sort', 10, 2);

    Let me know how that goes.

    Thanks

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount