• Resolved Anonymous User 13545031

    (@anonymized-13545031)


    Is there a way (via plugin or hook) to change a post date just before it is published?

    Background: We are running a travel blog with daily posts. All posts are scheduled to be published in the future (we only have internet a couple of times a week but want a new post ever day).

    So for example I would write about today’s (Dec. 19 2013) adventures and set this post to be published on Dec. 26.

    Now the post date in WordPress will be Dec. 26, but I want it to be Dec. 19. while the post should still be published automatically on Dec. 26. Also users are notified by email when a new post is published.

    I currently use a custom field to display the “real date” the post is about, but this messes up things like archives and the url scheme of the post that use the post date and not the custom field.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Here’s a good plugin where users can sign up to follow your blog and get emails of new posts. It’s based on the module in Jetpack that does the same think. However, you might consider using Jetpack since the module in it is more light weight and you get all the additional features Jetpack offers.

    http://wordpress.org/plugins/follow/

    As to the other issue, I can’t think of a way to do this, with out at least coding up a custom template file (but that would be just to display a different date). But let me ask this – Is the actual date of the adventure really that important? My question isn’t a tech support answer because I’m thinking more about your blogging style and method instead. Maybe a solution lies there. Could we see a link to your blog?

    The reason I ask, is because I’m wondering if the adventure is more important to your readers than the date it occurred. Maybe you could leave out references to a specific date and just ensure that your posts are published sequentially. Maybe use a naming convention of Day 1, Day 2, Day 3.

    You are already using scheduled posts so your readers are already getting a delay about your travels to begin with, does it matter what day the adventure occurred?

    I’m certainly not dismissing your idea and will happy to explore it more with you, but sometimes, when it comes to blogging, maybe rethinking our perceptions about it make it easier to do.

    Thread Starter Anonymous User 13545031

    (@anonymized-13545031)

    Hi and thanks for the reply!

    To your questions: We are currently travelling and blogging one post about each day. The blog post is published every day at 6pm and our readers have gotten used to that (we’ve be on the road for about a year). So the day is somewhat a crucial entity. The daily posts are also shown on a map marking the spot where we arrived at that date and linking to the blog entry (done via a custom plugin). You can see all that at http://omtour.de (in German).

    For the email notifications we are already using a plugin (Subscribe2). I just thought I’d mention it because this plugin attaches to the publish hook. If we didn’t have this requirement I could just publish the posts when I write them with the date of the day that I have been writing about and then use a filter to display only the posts up until a week before today. But this would make the notification impossible.

    Again thanks and I’m looking forward to your thoughts!

    To say that your blog is anything less than amazing would be an understatement. The way you’ve integrated the map with the posts in incredible and I am very impressed by it.

    Now, to your concerns. There is no built in way to backdate the posts (while at the same time using scheduled posts to publish them in the future).

    The only thing I can think of is to setup a cosmetic fix to display the dates a different way. Here me out on this one, but it will require some programming.

    First, if you are not already using a child theme. You will need to do so.

    Then, in the child theme you would need to create a new template file for single.php. Just copy the one from your theme into your child theme and modify it. The modification you would make would be to display somewhere, the custom field you are using to note the correct date for the post. Then, you could use CSS within the child theme to hide (or, reduce the prominence of) the built in published date. Maybe remove the little box it is in, display it on a line behind the German version of “Published on:” Now, since the actual date of adventure is being displayed on the post, you would then use CSS to give it prominence on the page.

    However, as you so rightly noted in your original post, this all causes confusion because it isn’t going to be in line with how the archive page is setup. So you would need to fix that too. Not to worry, you would then create an archive.php in your child theme. Again, you can copy over the original file from your theme folder and modify it. This one is going to be harder, but your are going to have to spend some time in the WordPress Codex to learn how archive pages work http://codex.wordpress.org/Creating_an_Archive_Index It is not going to be straight forward because you will need to do custom coding to force it to sort by the date used in the custom field you’ve created. There will be additionally issues because you will need to figure how to format the date in the custom field itself so that your code knows how to read it.

    In short, I can’t think of anyway to do what you want without getting your hands dirty, coding up custom template files in a child theme. Even then I suspect you may have some issues coding up the archive file to sort correctly. This method, as a solution, is pretty advanced and is require to require knowledge of php, WordPress hooks and filters and the loop.

    Unless someone comes along with a simpler idea that I can’t think, doing these cosmetic modifications might be your solution.

    Thread Starter Anonymous User 13545031

    (@anonymized-13545031)

    Thanks again for the pointers! I don’t really worry about getting my hands dirty since the map integration already is a plugin that I wrote from scratch. I am using a child theme and the date displayed with the post in the calendar style is already the custom field. You can see that when you look at the url scheme of a post and the not matching displayed post date. The archives had me worried though and I guess if no other suggestion comes up the way you pointed out will be the way I’ll have to go.

    Alternatively I could only think of maybe using a hook that fires when WordPress wants to publish a scheduled post but has not created the url yet. If I could then modify the post date with the value from the custom field before saving the published post I could backdate it while being published. I was looking for a hook in that direction but have not come up with anything that does not require extensive testing and debugging of WordPress.

    What about just changing the URL scheme. You are already naming the post using the Day 1, Day 2, Day 3 naming convention. Perhaps just change the permalinks to a more user friendly-format (maybe just the postnames only) will help clean up the user experience. I tend to think that the date permalink is a little technical and not very user friendly (to be honest, it has always struck me as a little anal-retentive!). It might be good for general publishing, like a magazine website, but in your use case, it presents a data and visual disconnect to your readers.

    The question then becomes, does having the date in the URL really enhance or make a difference to the readers, especially since you already are using a chronological naming convention in the post titles themselves? By having both in the URL, you are doubling up the data. Might it not be an user enticement to see Day 324 and then go to the site to see what day that occurred on?

    Thread Starter Anonymous User 13545031

    (@anonymized-13545031)

    Good point well made. I will definitively look into changing the url scheme. I guess I thought it made sense back when I set up the site so the user can easily see the exact date of the post from the url (which ultimately he can’t since it’s the date of publishing…). Then the wife started naming her posts like “Day 123: xxx” 😉

    But I still believe it’d be most elegant in this particular blog if the post date was the date written about in that post.

    Elegant yes, but a lot of dirty work too. You can fake and mask the elegance in by sending weekly digests of your blog posts to your users. The short option, of course, is simply to publish daily on the days you reference whenever possible (though I know you mentioned that is tough because net access isn’t always there). I think you’ve already done a fine job in masking the publishing by displaying the correct date in the post calender box. That alone is an elegant solution, I think changing the permalink structure gives it a little more polish (and you save yourself a ton of work, giving you more time to enjoy your travels with your wife!)

    Sometimes, I’ve found that in working with WordPress, it helps to rethink our perspectives about what we are trying to do. It helps sometimes to look at it from the average user’s experience as it actually is occurring, instead of how we are trying to make it occur.

    Thread Starter Anonymous User 13545031

    (@anonymized-13545031)

    Just a quick follow-up: I found a way to do what I wanted to using a custom plugin.

    The short version is to attach to the “publish_future_post” hook, when it fires change the date of the post to a value handed over in a custom field, save the post and then delete the custom field value from the meta table. If someone other than me is really interested 😉 I will publish the code on Github.

    I will redo the url schema, but I want to include a category slug and there is an issue with multiple categories that I will have to look into before I make the change.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to publish a post in the future, but with a post date in the past’ is closed to new replies.