Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #289309

    Hi guys,

    I am wondering if it is possible to make a slight change to the way posts get ordered by title. We have posts with words followed by numbers, and they’re not in the correct order. For instance, when ordering “Blahblah 1″, “Blahblah 2″, and “Blahblah 10″, the order comes out as:

    Blahblah 1
    Blahblah 10
    Blahblah 2

    I know it’s because only the first digit in the number is accounted for, but I was wondering if there is a change that could be made to force it to recognize two or more digits.

    Thanks for always giving great support,
    Brock

    #289406

    Hey understandchristianity!

    Thank you for using our theme.

    No, there is no possibility because the SQL sorting algorithm does not support this. The only way could be to hook into WP after the query and resort the result. But that is not an easy task and will make problems on pagination.

    Cheers!
    Günter

    #289561

    Ok, thank you.

    There may be another solution to my problem. The issue comes from the fact that I want posts to have a permanent order on certain pages, but I also need those posts to be ordered by “post date” within magazine elements.

    If I use the “order” field within WordPress to order the posts permanently on certain pages, then the magazine elements will take the order “0″ posts before the order “1″ posts, which are taken before the order “2″ posts.

    Could you point to the code that determines the magazine element order, and is it possible to code it to ignore the “order” field and only order by “post date”?

    If I didn’t explain this correctly let me know and I’ll try again. :)

    Thanks,
    Brock

    #289575

    Hi!

    As far as I see in the code, the default magazine query is only by date descending. See enfold/config-templatebuilder/avia-shortcodes/magazine.php Line 366ff.

    We also have a chance to hook into the query parameters, if it does not work:

    line 388: apply_filters(‘avf_magazine_entries_query’, $query, $params);

    Best thing you try and if you encounter problems, we can take a closer look.

    Best regards,
    Günter

    #289749

    I sort of figured out a workaround with the plugin Advanced Custom Fields. I created a custom field for the posts and within the functions for the plugin I use to create these posts (it’s a wiki) I set the get_posts array to grab the custom field.

    Thanks for your help!
    Brock

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

The topic ‘order by title with numbers’ is closed to new replies.