Ok, I solved this with a nice function, now the only thing left to do is to find a way to update all of the blog posts. doing this by hand will be really bad
here is the code that I used
add_action( ‘save_post’, ‘myplugin_save_postdata’ );
function myplugin_save_postdata( $post_id ) {
if ( ‘page’ == $_POST[‘post_type’] ) {
if ( ! current_user_can( ‘edit_page’, $post_id ) )
return;
} else {
if ( ! current_user_can( ‘edit_post’, $post_id ) )
return;
}
$mydata = get_the_time(‘Y’); // Do something with $mydata
$mymonth = get_the_time(‘F’);
update_post_meta( $post_id, ‘year_’, $mydata );
update_post_meta( $post_id, ‘month’, $mymonth );
}
Related Posts:
- get_post_custom stripping styling issue
- How to get Advanced Custom Field Value According using POST ID? [closed]
- Guest Author – How to display posts on /author/ archive page
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Saving Post Data in Another Database
- WP_Query custom field pass the post id
- If custom field is empty, use one from a previous post
- ACF Relationship – Get Parent’s Post Object
- How to make a local “scroll to ID” on post?
- How to detect if an ACF custom-field is really in use?
- How to protect pages with double authentication: password + email (in custom field)
- How set featured posts using checkbox in post edit screen?
- Custom Field in Featured image for A particular post
- Convert custom fields to post categories
- Update all posts automatically when using post_meta
- Prevent duplicate posts in wp_insert_post using custom fields
- Better post meta efficiency?
- Add custom field to all posts in specific category
- Adding a Nav menu to post admin
- meta_box or custom_field as a second tinymce post-instance?
- Create A Metabox For A Custom Field
- Paragraphs removed when using get_post_custom()?
- get post id in while loops outputting page id
- Populating a page with content from post custom fields
- How to change what the post creation page looks like?
- Sanitizing `wp_editor();` Values for Database, Edit, and Display
- Autoremove empty custom fields
- How to add a custom field after wp post
- Custom fields on a virtual page
- What Is meta_id In wp_postmeta?
- Get a custom field of all posts on current blog page
- Only display posts after current date
- How can I get a post field value using javascript?
- Automatic value for custom fields for posts
- WP_Query orderby not working with meta_value_num and menu_order
- How can I sort posts by the date and a custom meta field?
- How to display Common posts from specific Tag & Category with Shortcode
- Automatically add custom fields value to wordpress post
- Is there a way to notify specific users when new posts are published to specific pages?
- MySql query to get posts with all meta and terms
- Categories list into registration form
- Add a custom meta box in the post options that loads some html code in the header
- Query Posts With Over 1000 Views
- Cannot retrieve a custom RSS field from posts
- Saving custom fields to a custom taxonomy
- Hooking into the post editing screen for an existing page only
- Query Posts by Custom Field
- Redirect to another page using contact form 7? [closed]
- How to rate a post from Admin Side / Manually?
- How to I retrieve the ID from the Posts page?
- Create a list of posts with topic headdings
- Add field to user meta table in database when link is clicked
- Hide custom metabox value from custom fields
- Edit multiple custom post types while saving a new or edited post
- ACF to select posts not displaying on blog page
- if in category but only with post meta
- Getting property of non-object when looping through post objects from ACF
- Update post meta within save_post action
- Add hero image to home page (blog format) via the dashboard
- Add two custom fields as a default to the “new post” page.
- After ajax image is outside the “ tag
- How to display post list in a table layout (multiple queries in single loop)
- Edit custom fields in posts list
- Add multiple meta keys to a post at once
- Why my meta boxes won’t show in front post page?
- Will multiple category descriptions effect my search engine optimization?
- Automate post update for all posts?
- What snippet do I need to type to show my ACF field show up on my theme?
- ACF flexible content block not showing on live site (works locally)
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Post picker custom field on page
- Post meta not working
- ACF date picker to trigger category change
- How to work with posts and sub posts?
- Run a function when a custom post is update?
- Query on a repeater date (acf)
- Adding an option to post editor to show a site disclaimer or message
- Need to display a Jan 1st post as the site’s front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday
- How do I display posts ordered by a date custom field?
- WP_Query sort by meta_value_num or date
- Creating Ordered Query using Meta_key
- WordPress Request Post All Post ID in a Loop? [closed]
- How can I set and update the the_date according to a custom field of the post
- How to retrieve a post by inputing the url in a custom field and displaying it on an options page
- Custom fields in normal posts
- WP Query between posts custom fields [duplicate]
- get_the_ID() fails the first time, returns a value the second time it’s called
- Run function after post is updated
- Using Post ID and Page ID in same function
- Apply comment to different post (not the current post) [duplicate]
- How to only allow post to be deleted if custom field doesn’t exist
- get_post_meta property of non object
- How do I insert a custom field in a user submitted post?
- Attaching global meta to custom fields
- First Custom Post Custom Fields Empty After New Custom Post
- How enter custom post meta or custom field on box post list archive page?
- Read more opens attachment
- How to make internal links creating plugin to respect ACF?