Predefine WordPress publication time and time - wordpress

I'm just looking for a solution that will enter predefined date and time to every new post's editing window.
Due to some peculiarities of my site the post time should always be the same, only the dates may vary. But sometimes I have to add lots of posts bearing the same year and month and differ only by the date.
So the best solution would be to set desired fixed date and time for every new post, so that I could only edit the date if needed.
This would save my time greatly.
No matter if it would be a plugin or a functions.php code. But functions.php is preferred if it is able to interact with the backend.

Have you tried Automatic Post Date Filler? It includes a JavaScript based solution as I suggested in comments earlier, packed in a plugin with some options. Does this satisfy your needs?

Related

Update Custom fields 30 Days after

I am having trouble finding a solution. I am using ACF5.
I would like a field to automatically change its value 7 days after the post author has chosen a value.
I am using a select field (Featured) with 2 values (Featured, Not Featured).
If you have a solution with a different type a field that would work too.
I found this https://wordpress.stackexchange.com/a/85606/124674 However, I do not know how to to use it.
Your help is greatly appreciated.
In order to do so you need two things:
a) you need to know when user modified that field.
Therefore you have to add some modified date field where you put a timestamp of last change of the featured field. Additionally if you have a lot of posts you may have a user_modified field "flag" to mark specific entries as needing attention.
b) you need to have a cron task which runs every minute / hour
This task would scan the wp_postmeta table in certain time intervals. When it finds the field which was modified by user and the modification date is older than XX days then you switch the value to the desired one.
I know that this is an overall overview and you still have a lot of small tiny details to figure out but those depend on your scenario.

2sxc - Time field editor with seconds

Where to start if I need time field similar to DateTime "show Time picker",
but I also need seconds. If is posible to also hide date part it would be exactly what I need.
I accepted comment from iJungleBoy as solution,
even if I didn't create it yet.
When I become good enough to make it I will post it back.

How can I display Wordpress posts in a repeatable random order?

I would like to control the MySQL statement that Wordpress uses to give me a group of posts. Specifically, I would like to add this to the sql:
ORDER BY RAND(CURDATE())
This particular implementation has a fixed number of posts that will not be changing. However that would be boring for returning visitors and some posts that are down the page would likely never be seen. I would like to display the posts in a random order that is the same all day and then gets randomized differently the next day.
WP_Query allows for a rand function but it effectively does:
ORDER BY RAND()
The problem this causes me is that it randomizes differently each time it is queried. I want it to stay the same for every query all day. Seeding the randomizer with today's date accomplishes this. WP_Query however does not allow for seeding the randomizer. So how do I accomplish my desired end?

Stripping out fields from Variation in Woocommerce

I'm going to go ahead with what i'm suggesting here, but i thought i'd try and get someones thoughts at the same time
Cutting off the fat
I've got several products with 700+ variations. This becomes an issue with wordpress saving that product because it panics when it tries to save 8000+ fields and causes intermittent saving and ends up losing data.
However, looking at the variations in the backend, there are several fields that i'm not using in each variation:
weight
dimensions
virtual
downloadable
stock qty
sale price (and schedule)
etc.
If i remove these, thats at least 6 x 700 field = 4200 less fields that wordpress has to deal with, which would make saving an actual possibility.
I'm going to just defy the gods for this one and edit the woo commerce template directly to test it out.
I'm not 100% sure how to create a function that would remove these fields without harming woocommerce at this moment in time, if anyone know how, that'd be fantastic
I'll let you know my results.
I just dug around in the class-wc-meta-box-product-data.php file and there does not seem to be any easy way to remove built-in input fields. You would probably have to re-write the entire metabox.
What might be possible is a JS solution whereby you remove the fields you don't want. I am not sure at all, but if WooCommerce has proper isset() checks on all the variables its save routine then it shouldn't crash.
Or you could remove Woo's save routine and replace it with your own?
Woo's save action:
add_action( 'woocommerce_process_product_meta', 'WC_Meta_Box_Product_Data::save', 10, 2 );
This, like re-writing the entire metabox, puts you at risk of things breaking whenever WC is updated.
Just out of curiosity, how does one get 700+ variations?

Questions on building RSS feed

I am building RSS feed for the first time and I have some simple, direct questions that I was unable to find on the web, well at list in a sense that would be clear to me. Can you help me understand following
Which items should I include in RSS generation? should I always put in all the articles or what is the criteria when I query my articles for the feed?
What value should I set for pubDate? The specification says "The publication date for the content in the channel. For example, the New York Times publishes on a daily basis, the publication date flips once every 24 hours. That's when the pubDate of the channel changes.". I do not quite understand how to apply this to my feed. I have new articles daily, should I set the pubDate to let say 06:00 AM today and update it every day?
lastBuildDate: if I understand this right is the date of the latest updated item?
Which items should I include in RSS generation?
You should have one generic feed with all the new articles you post (for example: news). Additionally if you got your webpage split into categories, or you have some specific feeds (eg. calendar of the events) then it's good to create additional separate RSS for each one of them
What value should I set for pubDate? I do not quite understand how to apply this to my feed. I have new articles daily, should I set the pubDate to let say 06:00 AM today and update it every day?
Always set pubDate to the time when your news/articles went online. So if you have new articles daily pubDate should be a date when they were released to the public. Not random hour in the morning. Not the moment when you started writing them.
lastBuildDate: if I understand this right is the date of the latest updated item?
lastBuildDate is the most recent date when any of the results was posted or modified. Usually you should skip it - especially if your lastBuildDate will be simply a most recent pubDate. It's an optional parameter.
I use lastBuildDate only for calendar RSS feeds to show when the calendar was updated (as in calendars you not only add new entries but also often edit existing).
You should put every article, but the best is to provide different feeds for different categories, even search keywords. You can build it like any dynamic page, with a querystring.
that's not super important, you can put whatever. I don't think may feed readers use it.
theoretically it's the date the content changed. So the date of the latest updated item should work.
Something super important, since people are going to do polling on this page (meaning a lot of requests on the page)
- Cache it on your server
- Serve and Etag header and/or a LastModifiedDate. That way your server can respond with just a "not modified" if the client has it in cache already.

Resources