Our wordpress blog (currently version 3.4.2) has an external process that inserts posts directly into the database from a third party. I don't have the ability to change that, so don't bother telling me it shouldn't be done that way. I CAN change the insert statements though.
The posts show up and everything looks fine except that the RSS feed shows an invalid year (expecting 2013, instead getting -0001) in the date field:
<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
The post_date field in the wp_posts table for the post shows the correct date, and on the site the post has the right date. It shows up in the right place chronologically.
If I manually edit the post using the control panel and change the date even by just one second and re-publish the post then it fixes the feed.
This problem causes the RSS feed to not validate, and it's breaking other things. Help!
There are 4 dates stored for each WP post: Post_date, post_date_gmt, post_modified and post_modified_gmt.
I recommend you to insert the same date for both post_date and post_modified and see if it works.
Related
I want to change or reset the total_sales to 0 at worst.
When I modify in phpMyAdmin (wc_product_meta_lookup) nothing happens and everything goes back to the way it was before after a new order.
I searched for 2 hours without finding anything.
thank you in advance.
total_sales is a post meta field, a row in postmeta table. wc_product_meta_lookup just contains consolidated data from postmeta to avoid making multiple postmeta selects when product data are needed.
postmeta is the source of truth in this case, you need to set your desired value in there. Either directly in the database or using a custom field in the product edit view.
Reports (including total sales value in the dashboard widget) are dynamically generated, so I believe the value your setting in the database will just be set back to it's true value when WordPress runs.
According to the docs, you need to delete all prior orders (permanently) and clear your browser cache for new reports.
More info: https://docs.woocommerce.com/document/reports/#section-12
I have just updated the post on my blog changed its category and now its showing the current date instead of publishing date. How to display the publish date instead of the revision/update one.
ED website
A password to access is letmein Thank you in advance.
I think you must keep in a database field the initial date, and then you must modify the template in order to display the initial date not the last. But if you go to the Gui that can edited the post and you know the date you can update manual the date for a specific post. In Wp you can put feature or older date to a post.
I have written some php code that loops through the published posts on my wp site and when the Expiry Date (new field I added to each post) is <= to today's date, the post status is changed to draft.
It does change the status to draft however it duplicates the post. So I end up with 2 of the same posts, both set to "Draft".
I just want the original post status changed and that's it.
Not sure what I'm doing wrong here.
The echo statements are just for me testing the code.
Below is some of my code:
I am having troubles with my Worpress post date. As the picture shows, I can publish the post with 01-Jan etc. I only want to post the month with text, and no numbers. Any suggestions?
You mentioned in the comments that the date on the front end was displayed wrong. Therefore, I suggest you look at the PHP source that is creating that page.
It's possible that the date format has been explicitly set in there, especially if you are using a non-custom theme, so the format under 'Settings -> General' could be ignored.
I'm trying to show expired posts AFTER non-expired posts. How can I do this?
I've added a custom field "Expiration Date", in which I store the expiration dates in yyyy/mm/dd format. Problem is, if I order my results by this field, future expiry dates come first.
So I created a repeating cron-job which compares the dates and creates a secondary custom field "Expiration Date Passed" for posts whose dates have passed. I tried ordering by this field, but WP only shows posts with a value for this field - IE posts with no expiry date, or expiry dates in the future, don't show. So I tried auto-adding values '99999999' for any post which haven't expired yet. Problem is, WP can't order by custom field values THEN date- IE the first posts with value '99999999' are in a random order.
I also tried doing two queries for posts, one without expired posts, one with, then merging these two arrays. So the data is in the right order - but it screwed up WP's pagination.
Help, I'm running out of ideas!
Since you have an "Expiration Date Passed" custom field , you could first create two sets of Posts using that custom field in your get_posts arguments to differentiate between current & expired Posts
$meta_key and $meta_value
(string) (optional) Only show posts that contain a meta (custom) field with this key and value. Both parameters must be defined, or neither will work.
Default: None
extract from:
http://codex.wordpress.org/Function_Reference/wp_get_recent_posts
then you'll be able to sort each set the way you want
That might work, but I am trying to sort the posts on my category pages. Wp_get_recent_posts function is usually used for creating custom loops, not modifying 'the loop' in category (archive template) pages.
In the end I sorted it with this. I added this code to the top of my archive template:
global $query_string;
query_posts($query_string . "&orderby=meta_value&meta_key=Expiration Date Passed&order=DESC");
I created a "sort" custom field called "Expiration Date Passed". A cron job then looks to see whether the post has an expiration date. If it doesn't, or if the date is in the future, it puts the post's publish date + 20 years in the sort column. If the post's expiration has passed, it puts the post's publish date in the sort column. Thus it results in the order I was after:
1) Posts which haven't expired, in date order
2) Posts which have expired, in date order
Thought I would post that solution in case anyone else wanted to know.