I suppose it deleted the value when you had no URL in the content, so $audio_raw was empty.
if ($audio_raw && get_post_meta( $post_id, 'audio_url', true ) != $audio_raw) {
// update the meta field
update_post_meta( $post_id, 'audio_url', $audio_raw );
}
checks that $audio_raw isn’t false/null/empty and that $audio_raw isn’t the same as the string currently in audio_url
.
BTW, I’m pretty sure
remove_action('save_post', 'save_url_link', 10, 2);
Doesn’t really to anything, since you’re already in that hook when you’re removing the hook from save_post
. It won’t run twice, so no need to remove it.
Related Posts:
- How to automatically apply woocommerce product title to all product images alt tags?
- Add custom field to attachments in a specific category
- How can update custom meta for all posts
- Passing the custom field values in the wp_get_current_user array function
- Firing schema via code in functions.php doesn’t work
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Trying to retrieve post meta
- Which PHP page is the Default Posts Page
- Can’t save php string to a custom field
- Why does this update_post_meta function not delete the custom field itself?
- How to show/hide php table rows based on the content of custom fields
- Custom meta box values are not getting saved for my custom post type
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- WP All Import / Update stock quantity from multiple XML files
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- How to add data to a custom field at the wp_users table?
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Hide a div when a custom field is empty
- Conditional On custom field plugin metabox
- Delete images from media library when user deletes an image from ACF Gallery
- Updating Metadata with Shortcode
- Products listing check if meta checkbox is checked
- Trying to update Woocommerce meta values
- Is it possible to update the dataset using update_post_meta
- Block error message in foreach loop when looping through ACF field
- Hide a div if the fiels is empty
- How do I get the value of a current user’s custom field?
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- Display custom meta box in my template file
- ACF Date fileds to Age Convert [closed]
- Appending an ACF custom field to the page title
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom Admin Menu Report for Specific User ID
- ACF number less than comparison not working
- Display all values of custom a field created with ACF on a page
- Allowed memory size of 268435456 bytes exhausted (tried to allocate 7146491840906359738 bytes)
- How do I get the author’s page url from their ID?
- How to check from which page the user is coming to the current page?
- Execute only on a certain page
- How do I know what variables are passed in a filter/action and what their meaning is?
- Wrap each shortcode in array to div
- Warning: array_pop() expects parameter 1 to be array, boolean given
- Replace comment avatars and links at the same time
- Check if Product is in a Specific Category in Functions.php
- Adding ads code between comments
- How to Display Image Meta underneath EVERY image in EVERY post
- Limiting woocommerce line_total decimal length
- Shortcode content filter?
- Swapping wp_dropdown_categories function with wp_category_checklist
- only show container with next/prev links if they exist?
- Populate dropdown with Child Pages based on Parent Page chosen
- JS file work only in index page
- Error in custom php function doesn’t exist
- Custom shortcode outputs plain text instead of HTML at top of post
- how can i use $_COOKIE[] + PostID to execute the below code?
- What’s the uses of wp_cache_set() or wp_cache_add()?
- Create Page To Count Comments For Each Post In WordPress Site
- Can anyone offer any help with this function?
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- height should be set to auto to avoid pixelation in the post thumbnail function
- Can i put my shortcode inside a variable in php files?
- Moving code from theme header to functions.php
- Show meta box only for default page template
- Can’t access site after making changes to the functions.php [closed]
- Best way to use a large array in function
- Setting user nickname and displayname to shortened email
- HTML Special Characters in URL string [closed]
- Create page template via functions.php?
- CSS change in woo commerce Place Order Text [closed]
- child parent styles enqueue order
- Add URL parameter to all internal links using a specific theme
- Warning: call_user_func() expects parameter 1 to be a valid callback, function
- Change MySQL PDO connection to a WPDB connection
- Filter unique custom field value based on custom taxonomy category or other custom field
- Query pulling a single post per month
- Modify WooCommerce used to get all orders in dashboard
- Can’t log in to WordPress wp-admin after adding code to functions.php
- Search by date in WordPress
- Illegal string offset checkbox
- Trying to add some custom text into WordPress Post title via function.php
- I got big white screen when i attach main style sheet of Html in functions.php
- Using Javascript On Page – Header and Footer Now Missing
- Add Product Permalink in woocommerce admin order page
- How do I make comment-reply-button with that takes to comment reply form on click
- How to generate customized filtered output for the gallery
- Allow BBPress participant role to trash topics
- Display Year and Month from custom field + Age Calculator
- Display Content Based on Custom Field Value
- insert thumbnail image from php script
- WordPress rating by views [closed]
- Get author meta of all writers
- Custom field in title
- Trying to see if page is category or single and displaying title with appropriate heading tag
- WP Fatal error: Call to undefined function get_template_directory_uri()
- Remove default Image Sizes
- A better way to write this php function
- Why a class property becomes empty?
- Hide category by tag
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico