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

Combine multiple custom field values into single value

Updated <?php global $post; $address_name = str_replace( ‘,’, ”, get_post_meta( $post->ID, ‘_mfl_entry_address_name’, true ) ); $address_street = str_replace( ‘,’, ”, get_post_meta( $post->ID, ‘_mfl_entry_address_street’, true ) ); $address_line_2 = str_replace( ‘,’, ”, get_post_meta( $post->ID, ‘_mfl_entry_address_line_2’, true ) ); $address_line_3 = str_replace( ‘,’, ”, get_post_meta( $post->ID, ‘_mfl_entry_address_line_3’, true ) ); $address_postcode = str_replace( ‘,’, ”, get_post_meta( $post->ID, … Read more

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

Where is the key _wp_page_template passed?

The HTML attribute name is what is sent to the server. There is some PHP code reading it and storing it with a specific key in the database. The HTML name and the database key don’t have to be the same string. The PHP code can use a completely different name or split one value … Read more

Categories pages Tags metabox, pages, post-meta

Adding custom fields (post meta) before/during wp_insert_post()

You can hook your function to the wp_insert_post action hook: add_action( ‘wp_insert_post’, ‘wpse128767_add_meta’ ); function wpse128767_add_meta( $post_id ) { add_post_meta( $post_id, ‘key’, ‘value’ ); } To make sure your metadata has been added before any other insert hooks run, give it a higher priority: add_action( ‘wp_insert_post’, ‘wpse128767_add_meta’, 1 ); By default add_action() uses a priority … Read more

Categories custom-field Tags custom-field, hacks, post-meta, wp-insert-post

Is there a filter for get_post_custom()?

The quickest way to answer this question is to follow the code. See get_post_custom in Codex. Scroll down to Source Code section: get_post_custom() is located in wp-includes/post.php There we’ll see that get_post_custom calls get_post_meta, which then calls get_metadata, which points us to: get_metadata() is located in wp-includes/meta.php there we’ll finally see the available filter: $check … Read more

Categories plugins Tags filters, plugins, post-meta

Searching by meta values showing inappropriate result

First of all, one never should rely on raw $_REQUEST: believe me, this is a security issue. PHP has 2 functions: filter_input and filter_input_array that helps you to sanitize your request data. In addition, in your request dump I don’t see any $_REQUEST[‘custom_bath’], but you are using that value, that can be a cause for … Read more

Categories search Tags meta-query, post-meta, search

Replace title column in post list with post meta value

You can use the_title filter. add_filter(‘the_title’, ‘my_meta_on_title’,10, 2); function my_meta_on_title($title, $id) { if(‘booking’ == get_post_type($id)) { return get_post_meta( $id, ‘booking_first_name’, true ).’ ‘.get_post_meta( $id, ‘booking_last_name’, true ); } else { return $title; } }

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

how do I set a schedule event to modify all posts’s meta value weekly or monthly?

wp_schedule_event() is what you are looking for. With this function you can create a cron jon that WordPress will axecute on the specific interval you configure. This function should be called only on plugin activation and the scheduled event should be cleared on plugin deactivation. For example: //Create the weekly and monthly interval add_filter(‘cron_schedules’, ‘cyb_cron_schedules’); … Read more

Categories post-meta Tags post-meta

Group WP_Query by meta_key date

A good approach to this would be to first fetch all posts sorted by date, and then group them. As you state the time custom field is in the format Y-m-d, so you can properly sort your posts using orderby => ‘meta_value’ (not meta_value_num, as it currently is, which casts the value to a numeric … Read more

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

wp_update_user isn’t instantly?

global $current_user; get_currentuserinfo(); if (isset($_POST[’email’])) { wp_update_user( array(‘ID’ => $current_user->ID, ‘user_email’ => $_POST[’email’]) ); unset($current_user); get_currentuserinfo(); //just in case } echo ‘<p>You’ll recieve a mail here: ‘ . $current_user->user_email . ‘</p>’; Now it should work, the problem was on the get_currentuserinfo() function, because it checks if the variable is already set and is an instace … Read more

Categories post-meta Tags post-meta

update_post_meta and get_post_meta not working

Try with this code, //Metabox Hook add_action(‘add_meta_boxes’,’stars_meta_box’); //Metabox Init function stars_meta_box(){ add_meta_box(‘first_name_meta_box’, ‘First Name’,’first_name_meta_box_html’,’spark_stars’,’normal’,’default’);); } //Metabox Html function first_name_meta_box_html($post){ wp_nonce_field(‘first_name’,’first_name_meta_box_nonce’); $value = get_post_meta( $post->ID, ‘first_name_meta_box_key’, true ); echo ‘<label>First Name: </label> <input type=”text” name=”fname” value=”‘ . esc_attr($value) . ‘”/>’; } //Save Hook add_action( ‘save_post’, ‘my_save_meta_box’ ); //Save Metabox Value function my_save_meta_box($post_id){ //you might want this … Read more

Categories metabox Tags metabox, post-meta
Older posts
Newer posts
← Previous Page1 … Page152 Page153 Page154 … 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