I have a post in my WordPress website, which has lot of custom fields. I have an Excel sheet with "post link" - "custom field data" combination. That custom field (video URL) is already set for each post, but now I need to change and update those links based on the Excel sheet. I don't have a "post_id - post meta data" combination, just link and appropriate meta data value. … [Read more...] about Update post meta data (custom field) by post link
Update post meta data wordpress
How do I access post meta data when publishing a new post in Gutenberg?
function process_meta( $ID, $post ) { if (get_post_meta($ID, 'my_post_meta_field', true)) { // do something } } add_action('publish_post', 'process_meta', 10, 2); The problem is that post meta fields have not yet been saved to the database when this hook (or any others that I'm aware of) fires, so unless a post draft has already been saved, my_post_meta_field always appears empty at this point in my code. … [Read more...] about How do I access post meta data when publishing a new post in Gutenberg?
wordpress simple post multi rating with post_meta and user_meta
foreach ( $ls_up_votes as $key => $value ){ var_dump($key,$value); if ( $key == $currentusr ){ unset( $ls_up_votes[$key] ); } } When I add the user input 2 times, the unset commands should remove the previous array that was added by the same user and add the new one, instead its adding all 2 times.Here is what I am getting: … [Read more...] about wordpress simple post multi rating with post_meta and user_meta
WordPress is stripping escape backslashes from JSON strings in post_meta
{ "0": { "name": "Chris", "url": "testdomain.com", "comment": "\u00a5 \u00b7 \u00a3 \u00b7 \u20ac \u00b7 \u00b7 \u00a2 \u00b7 \u20a1 \u00b7 \u20a2 \u00b7 \u20a3 \u00b7 \u20a4 \u00b7 \u20a5 \u00b7 \u20a6 \u00b7 \u20a7 \u00b7 \u20a8 \u00b7 \u20a9 \u00b7 \u20aa \u00b7 \u20ab \u00b7 \u20ad \u00b7 \u20ae \u00b7 \u20af \u00b7 \u20b9" } } Unfortunately after I save it with update_post_meta, it comes out looking like this: … [Read more...] about WordPress is stripping escape backslashes from JSON strings in post_meta
How to Create and Use WordPress Custom Fields • WPShout
Quiz Time! In most situations, the best function to add custom field data to a post is:update_post_meta()add_post_meta()get_post_meta() get_post_meta() always requires:A post ID to targetA key to targetA value to search for and retrieve Omitting get_post_meta()‘s third argument, or setting it to false, results in:The custom field data not being sanitized for outputAn error if the targeted custom field does not exist for the targeted postThe custom field data being passed in as an array rather than a string Answers and Explanations A. add_post_meta() behaves strangely by default if the custom field already exists for the post. update_post_meta() behaves sensibly, adding the custom field if it doesn’t exist and updating it if it does. A. This ID is the function’s first argument. If B (the second argument) is omitted, the function will return an associative array of all custom fields associated with the post. C is unrelated to how get_post_meta() works. C. Setting … [Read more...] about How to Create and Use WordPress Custom Fields • WPShout