• Hello friend. Thanks for this cool plugin. I want to use it on a historical site, and I need to display historical dates of past years in a separate block.
    Everything is fine, except for sorting.
    Is it possible to display the headings in alphabetical order? Numbers by age.
    The thing is that in my historical event headings, annual events come first, and I need the years to be sorted by age.
    Now I use the eventon plugin for these purposes, it perfectly sorts my events in ascending order, but it works very slowly and in principle does not suit me.
    Here are some screenshots of how it works now on eventon and in your plugin. I want to get rid of Eventon. The only question is sorting. If there was an opportunity to somehow make sorting, I would be grateful. Thank you

    Screenshots:
    Sorting – On This Day (by Room 34)

    Sorting – On This Day (by Room 34)

    Correct sorting – Eventon

    Correct sorting – Eventon

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter madinfinity

    (@madinfinity)

    Please!

    Plugin Author room34

    (@room34)

    Hi… the links to the screenshots are not working for me. However, as I understand it you’re trying to have the query for On This Day sort the returned posts alphabetically by title, rather than chronologically by publish date, is that correct? If so, you could use a bit of custom code in your theme, leveraging the pre_get_posts action. The main challenge would be targeting the correct queries so it’s not running on every query. I think something like this should work, but I haven’t actually tested it:

    add_action('pre_get_posts', function($query) {
    if (
    !is_admin() && // Only run on front end
    !$query->is_main_query() && // Don't run on main query
    is_array($query->get('date_query')) && // Run if date_query is an array
    !empty($query->get('monthnum')) && // Run if monthnum is specified
    !empty($query->get('day') // Run if day is specified
    )) {
    $query->set('orderby' => 'name');
    $query->set('order', 'ASC');
    }
    }, 10, 1);

    There’s not a really simple way to determine if the query is for On This Day, so I loaded up as many specifics as I could.

    Thread Starter madinfinity

    (@madinfinity)

    Thank you.
    Please tell me where I should put this code?
    Where should I upload screenshots so you can see them?

    Plugin Author room34

    (@room34)

    The code can go in your theme’s functions.php file.

    You can put the screenshots wherever you want… they’re just not there anymore on the sharing service you used.

    Thread Starter madinfinity

    (@madinfinity)

    Thank you

    Thread Starter madinfinity

    (@madinfinity)

    syntax error, unexpected token =, expecting )

    Hello, I apologize, but this is what I got when I tried to use your code

    Plugin Author room34

    (@room34)

    Sorry, that was a careless mistake I would have caught if I had tested the code.

    In the fourth line from the end, replace this:

    =>

    with this:

    ,

    Thread Starter madinfinity

    (@madinfinity)

    Thank you, it works

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