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

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

Correct processing of `$_POST`, following WordPress Coding Standards

Correct processing of `$_POST`, following WordPress Coding Standards

Categories post-meta Tags coding-standards, post-meta, sanitization, save-post

How do I add advanced custom fields / meta fields to Elasticsearch? [closed]

Lets break this down, Advanced Custom Fields (ACF) does save the data as custom field/post meta, I guess it seems all to obvious, but it is better to confirm it, and ElasticPress does set up custom fields automatically to include them into the search index. ElasticPress does this unless the meta data is hidden, which … Read more

Categories plugins Tags advanced-custom-fields, plugins, post-meta, search

Order posts by meta value and Date

If you want both posts that have and do not have a meta key, you need an OR relation meta query to select both posts with key and those where it does not exist. $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_post_like_count’, ‘compare’ => ‘EXISTS’ ), array( ‘key’ => ‘_post_like_count’, … Read more

Categories wp-query Tags meta-query, post-meta, recent-posts, wp-query
Older posts
Newer posts
← Previous Page1 … Page168 Page169 Page170 … Page204 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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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