Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1467361

    Hi,
    I would like to sort my custom posts oldest to newest.
    I have tried various plugins that promise to let you choose to sort categories ascending versus descending but none seen to work.
    I wonder if this is because of the way I am putting out my thumbnails with this custom code:

    Is there a way I can switch to oldest to newest sort order?
    Thanks

    #1467423

    Hey lucybb2,

    Thank you for the inquiry.

    There is no option for this by default but you can use this filter in the functions.php file to adjust the sorting of the blog posts in the grid.

    add_filter('avia_post_slide_query', 'avia_post_slide_query_mod');
    
    function avia_post_slide_query_mod($query)
    {
        $query['orderby'] = 'date';
        $query['order'] = 'DESC';
    
        return $query;
    }

    Best regards,
    Ismael

    #1467480

    This code didn’t work for me. There was no error. Just no change.
    Thanks for trying.
    Lucy

    #1467503

    Hi,

    Thank you for the update.

    Where did you place the blog posts element? Please provide a direct link so we can check it. Also, try replacing the order value from DESC to ASC. Let us know the result.

    Best regards,
    Ismael

    #1467524

    Thanks.

    It is this page: https://guardingtheguards.com/category/journals/constabulary-gazette/

    In my functions I have this code putting it out.
    add_filter(“avf_post_slider_args”, function($atts, $context) {
    if ($context == “archive”) {
    $atts[‘type’] = ‘grid’;
    $atts[‘columns’] = 5;
    $atts[‘preview_mode’] = ‘custom’;
    $atts[‘image_size’] = ‘thumbnail’;
    }
    return $atts;
    }, 10, 2);

    When I added the code you gave me here to functions, it did nothing. No error, but no change.

    When I change to ASC the order does change but it makes no sense, it sort of seem to randomise the order.

    I note I am trying to order by post date and my post dates start in the 1970s and got up to the present.

    Thanks

    Lucy

    #1467632

    Hi,

    Are you trying to sort the posts based on the date in their title, e.g., “Constabulary Gazette, Jun 1980”? Please note that the filter will sort the posts based on their publication date. Unfortunately, there is no option to sort posts based on text in the title.

    Best regards,
    Ismael

    #1467648

    No, I am trying to sort on their publication date (which is each case I have manually set to the title date).

    There are lots of plugins that offer to do this, e.g.

    But they don’t work for me so I can only guess that is because of way I am putting out the thumbnails for Enfold?

    Thanks

    #1467713

    Hi,

    Thank you for the info.

    It seems that the sorting is not working due to the custom query in the archive.php template. We’ll get back to you once we find a suitable modification.

    Best regards,
    Ismael

    #1469517

    I was trying to figure this out as well. Was a suitable modification found?

    #1469526

    Hi,


    @cmactv
    : Have you tried using the avia_post_slide_query filter?

    add_filter('avia_post_slide_query', 'avia_post_slide_query_mod');
    
    function avia_post_slide_query_mod($query)
    {
        $query['orderby'] = 'date';
        $query['order'] = 'ASC'; 
    
        return $query;
    }

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.