Site logo

Archived topic

update post to show on homepage without changing Original post date

6 replies · Started by Melissa on October 22, 2021

Viewing posts 1–7 of 7

I have the Published date AND updated dates showing using a bit of extra css

CSS
/* Display updated date */
.posted-on .updated {
    display: inline-block;
    margin-right: 1em;
}
/*Add date prefixes */
.posted-on .updated:before {
    content: 'Updated: ';
}
.posted-on .entry-date:before {
    content: 'Published: ';
}

But The dates are wrong. How do I update a post so that it will show on the homepage, but still have the original publish date? Right now, when I update a post, it changes the Published date and the updated date at the same time.
post date
For example, this post was originally written in 2015. But it's displaying as thought I just wrote it a couple of weeks ago.

Hi there,

can you share a link to that post so i can see whats going on ?

@David,
Thank you for replying. I've added a link to my site in the private info box so you can see. I got the original question semi-sorted out. I use wp show posts to generate content and Elements to create an insertion hook. So that takes care of the "display" order on the homepage.

The still-present issue for me is how the Category page contents are sorted. They still show the original publish date with the newest at the top.

How do I force the Categories to sort by the Updated/Modified date rather than the original publish date?

Thanks!

Are you using any other functions to modify the dates?
If i check the HTML of the first post, as you pointed out above, the Updated and Published date are identical.

Are you using any other functions to modify the dates?
If i check the HTML of the first post, as you pointed out above, the Updated and Published date are identical.

No, just the stock publish box in wordpress. No plugins or mods.

publish-box

Sorted. I solved it by adding a function-->

function orderby_modified_posts( $query ) {
    if($query->is_category()) {
            $query->set( 'orderby', 'modified' );
       }
}
add_action( 'pre_get_posts', 'orderby_modified_posts' );

Thank you for the assist.

Glad to hear you got it resolved

This archived topic is closed to new replies.