• Resolved idet2

    (@idet2)


    Hello!

    First let me thank you for this wonderful plugin.

    I would like to know how do you sort the announcements with the same “announcement date”. Do you sort them alphabetically or do you use any other way of determining which should go first or second?

    I have a few announcements with the exact same “announcement date” but I would like them to appear according with the publication date.

    If requested I could change any values in the database manually!

    Regards

    https://www.ads-software.com/plugins/timeline-express/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter idet2

    (@idet2)

    I ‘ve found out that the “announcement_date” value is inserted in the wp_postmeta table as a “meta_value”

    Changing that, changes the date that appears on screen but doesn’t reorder the posts.

    Any ideas what is wrong and what I can do with that?
    It seems to me that in order to actually force the re-order the “Update” should be pressed which means that something else must also be changed….

    Best

    Plugin Author Evan Herman

    (@eherman24)

    Hi Idet2,

    The announcement date is stored inside of the wp_postmeta table, as it is a custom meta field that we have defined, which is assigned to a custom post type. The plugin queries the database and orders the announcement based on this value – as I’m sure you’ve figure out.

    I’m not sure it’s possible to query and order by one value, and override it based on the published date. I think it has to be one or the other, unless a second, custom query, is performed on the returned results.

    Let me do some quick testing and see what I can come up with.

    Evan

    Plugin Author Evan Herman

    (@eherman24)

    Hi Idet2,

    After some quick testing, I’ve come up with the following bit of code that seems to be working well.

    Go ahead and copy the following snippet directly into your active themes (ideally a child theme to prevent overrides on updates) functions.php :

    /**
     * Filter the Timeline Express query 'orderby' param & add a date fallback
     *
     * Timeline Express sorts by the announcement date by default.
     * Use this function to fallback to the published date when two
     * or more announcements are using the same announcement date.
     * This allows for manual control over the order of announcements.
     *
     * Reference: https://www.ads-software.com/support/topic/order-same-date-timeline
     * Source Code: https://github.com/EvanHerman/timeline-express/blob/master/lib/classes/class.timeline-express-initialize.php#L86
     */
    function timeline_express_sort_by_published_date_fallback( $args, $post, $atts ) {
    	$args['orderby'] = $args['orderby'] . ' date';
    	return $args;
    }
    add_filter( 'timeline_express_announcement_query_args', 'timeline_express_sort_by_published_date_fallback', 10, 3 );

    You’ll see that I’ve added a ‘date’ fallback to the orderby parameters. This means that when the initial query parameters are identical (eg: two announcements share the same announcement date), the date that the announcement was published on will be used.

    This should be what you are after. Feel free to give things a testing and let me know how it works out. If successful, I will add it to our ‘to do’ list for future updates, so we can get this included in the core code as the default behavior.

    Thanks!
    Evan

    Thread Starter idet2

    (@idet2)

    Evan,

    thank you very much for the update! I ‘ll try it tomorrow and let you know of the results!

    Once again appreciate your hard work!

    Regards

    Thread Starter idet2

    (@idet2)

    Evan,

    indeed it’s working! The only problem was that already published announcements were re-sorted after adding your code.

    So I had to sort them manually using the publication date since it’s working!

    Once again thank you very much for the development and for your effort!

    Looking forward to have this feature directly in the plugin!

    All the best!

    Plugin Author Evan Herman

    (@eherman24)

    No problem at all. Thanks so much for keeping me updated on the issue.

    If you wouldn’t mind – we would love it if you could leave us a positive review here in the repository:
    https://www.ads-software.com/support/view/plugin-reviews/timeline-express

    Thanks again and have a wonderful rest of your day!

    Evan

    Thread Starter idet2

    (@idet2)

    Sure thing!

    Just did!
    Thank you very much once again!

    All the best!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Order same date Timeline’ is closed to new replies.