Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

post-meta

Use ajax to update_post_meta

That will not work because you are referring to a single php file, instead the the whole WordPress environment. There’s a easier way to use ajax in WordPress. Use admin_url(‘admin-ajax’) as the form action, then put the function that will answer the ajax call in the theme’s functions.php. More detail here in this answer

Categories PHP Tags ajax, custom-field, mysql, php, post-meta

Inserting Hundreds of Thousands of Posts at Once

There are two reasons I can think of that may cause negative impact wp_insert_post retrieves the post from the DB after writing it to it. this is not fun but should have only a constant impact, so I’m guessing it is not your main problem Each post is being stored in memory as part of … Read more

Categories MySQL Tags mysql, post-meta, wp-insert-post

Formatting custom meta box date from YYYY/MM/DD to a more readable alternative

but when I visit a month with no posts my template returns the date “January 1970” instead. Yes. That will happen. UNIXTIME began on Jan 1, 1970. That is “0000/00/00” but negative numbers work back until sometime in 1901. strtotime will return false for anything outside that range, including your nonexistent dates. date will assume … Read more

Categories custom-post-types Tags custom-field, custom-post-types, date-time, metabox, post-meta

unable to save post meta on single field with multiple selects

In your save code, the value of $field[‘id’] is event_timeframe, which does not exist in $_POST, so your options will never save. You need to dig down into your options array to get to timestart and timeend: // loop through fields and save the data foreach ( $event_infobox_fields as $field ) { foreach ( $field[‘options’] … Read more

Categories metabox Tags metabox, post-meta, save-post

Save default value for empty or missing post meta

If you want to and only need to do what @tf suggested, what is just to take care of displaying a 0 if no value is present, you can construct a function to do so like this: function wpse121165_return_carprice() { $ecpt_carprice = get_post_meta($post->ID, ‘ecpt_carprice’, true); if(! empty( $ecpt_carprice ) ){ return $ecpt_carprice; } else { … Read more

Categories query Tags post-meta, query

update_post_meta() whenever custom post type is updated

You’re right to use ‘save_post’ action hook. Try this: <?php add_action(‘save_post’, ‘some_function’); function some_function($post_id) { if(get_post_type($post_id) != “VA_LISTING_PTYPE”) return; $meta_value = get_post_meta( $post_id, ‘featured-cat’, true ); if($meta_value != 1) return; update_post_meta($post_id, ‘website’, ”); update_post_meta($post_id, ‘twitter’, ”); update_post_meta($post_id, ‘facebook’, ”); } if you’re on WordPress 3.7 or higher, you can use it this way: add_action(‘save_post_VA_LISTING_PTYPE’, ‘some_function’); … Read more

Categories custom-post-types Tags actions, custom-post-types, post-meta, save-post

Using radio button meta data from a custom meta box

$response_radio = $_POST[‘meta-radio’]; if ($response_radio==”radio-one”) { //do your stuff } elseif ($response_radio==”radio-two”) { //do other stuff } I think this is what you are looking for

Categories posts Tags metabox, plugin-development, post-meta, posts, radio

Efficient way to update multiple post meta

Perhaps using SQL statement? Direct SQL queries are very dangerous, especially when updating the DB. At the very least you will get any object cache out of sync and you might miss execution of import action and filters. If this update is something that is rarely done it is better that it will take one … Read more

Categories wp-query Tags post-meta, wp-query

Get a post_id where meta_value equals something in a serialized meta_value field

I would strongly suggest to separate the products and not to put them all into one array. Or even to create a taxonomy companies, but this is more up to the while design and maybe a bad idea. Nevertheless this is a nice question to solve, so let’s play. So, the ‘prefix_products’ meta key is … Read more

Categories custom-field Tags custom-field, id, post-meta

ACF Upload Image in repeater from front-end with custom form? – add_post_meta()

ACF Upload Image in repeater from front-end with custom form? – add_post_meta()

Categories custom-post-types Tags advanced-custom-fields, custom-field, custom-post-types, post-meta
Older posts
Newer posts
← Previous Page1 … Page166 Page167 Page168 … Page203 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress