• Resolved iampontus

    (@iampontus)


    Hello forum!

    I’m new to wp and I have a problem related to posts showing up in wrong order. The site has categories for posts, and all posts with the category ‘Events’ are showing up in ascending order for some reason (old events are showing on top). I would like the posts under “Upcoming Events” to show up in the same order as under “Latest News”, with the most recent post on top.
    I’ve dubble checked that time zone is correct and there is no “sticky posts” used. I’m don’t think is related to plugin conflicts, since it only applies to Event-posts.
    I’m sure there is an easy explanation why, and I would be truly grateful for any help fixing this!

    The site is: dutchchamber.se

    Kind Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • can you post a direct link to the web page where this happens?

    I checked the ‘events’ category archive page, and the post order seems to be normal with the latest post at the top.

    Thread Starter iampontus

    (@iampontus)

    Thanks for your quick response (unlike my own…) This would be at the main page under the headline “Upcoming Events”, but also under the link for events. The event on top shows a post for an event in August, and at the bottom the an event for December is showing. This is of course “event dates” and not publish dates, however the post for the top event was published back in July and the newest one is from earlier this month.

    Many thanks for you assistance!

    the direct link for ‘events’ is going to a page which is using a page template page-events.php

    what is the full code of that page template?

    Thread Starter iampontus

    (@iampontus)

    Thanks to your guidance I was able to locate the code to modify. The order for both page-events.php and front-page.php had order set to ASC. This I changed to DESC which solved the problem.

    Thanks again for brilliant help!

    (Posted the code below incase it could help other rookies out there)

    <h2>Upcoming events</h2>
                    <hr>
                    <?php
                    $args = array(
                        'numberposts' => 5,
                        'meta_key' => 'start_date',
                        'orderby' => 'meta_value',
                        'order' => 'DESC', // Changed from ASC
                        'meta_query' =>array(
                            array(
                                'key' => 'show_on_front_page',
                                'value' => '1'
                            )
    
                        )
                    );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Posts are showing up in ascending order’ is closed to new replies.