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 datetime custom meta field using update_post_meta() function

it seems that you’re using that plugin in a wrong way. It’s not necessary hook to save_post because the plugin do it for you. Simply register your meta box and your fields. To retrieve the values check this

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

Why am I getting an infinite loop with have_posts?

Look at this answer: get custom post type by tag I believe you’d use $flagged_stores->the_post() inside while loop.

Categories post-meta Tags loop, post-meta, recursive

WordPress Admin Panel search posts with custom post meta values along with title

With this code you can search in post list in WordPress Admin Panel with custom post meta values along with title and other default fields. Please, add below code in functions.php file: if (!function_exists(‘extend_admin_search’)) { add_action(‘admin_init’, ‘extend_admin_search’); /** * hook the posts search if we’re on the admin page for our type */ function extend_admin_search() … Read more

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

Transients vs CRON +Custom Fields: Caching Data Per Post

I think I would write a wrapper function around custom fields, something like this: function get_post_transient( $post_ID, $meta_key, $update_function ) { $current_value = get_post_meta( $post_ID, $meta_key, true ); if ( is_array( $current_value ) && $current_value[‘expiration’] < date(‘U’) ) return $current_value[‘data’]; $new_value = call_user_function( $update_function, $post_ID ); update_post_meta( $post_ID, $meta_key, $new_value ); return $new_value[‘data’]; } and … Read more

Categories custom-field Tags cache, cron, custom-field, post-meta, transient

How Do I Use WP_Query to Run This Database Query as Search Result?

Well, perhaps the answer could not be found in the WP_Query class for what I was trying to accomplish. Below is the final code that I plugged in to my functions.php file. I ultimately ended up search the WP_Query Class found in the wp_includes/query.php file. What I discovered is that there are a number of … Read more

Categories custom-post-types Tags custom-post-types, post-meta, pre-get-posts, search, wp-query

Create meta boxes that don’t show in custom fields

All post meta is shown in the custom fields, unless it begins with an underscore. So to ‘remove’ post meta from the custom fields metabox, you simply have to give it a name, beginning with an underscore. You’ll then be responsible for saving/updating the post meta (adding your own metabox where necessary).

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

List posts under meta_value heading

You should use some of WordPress’s built in functions, there is even a new meta compare parameter. You can create, for example: $state = get_post_meta($post->ID, ‘meta_state’, true); //the meta value to compare $query = new WP_Query ( array( ‘meta_key’ => ‘project’, ‘meta_value’ => ‘$state’, ‘meta_compare’ => ‘<=’, ‘post_type’ => ‘projects’ ) ); //spit them out … Read more

Categories post-meta Tags list, post-meta

Clean up output added via wp_head()

You can remove some of the header stuff with the following. // remove unncessary header info function remove_header_info() { remove_action(‘wp_head’, ‘rsd_link’); remove_action(‘wp_head’, ‘wlwmanifest_link’); remove_action(‘wp_head’, ‘wp_generator’); remove_action(‘wp_head’, ‘start_post_rel_link’); remove_action(‘wp_head’, ‘index_rel_link’); remove_action(‘wp_head’, ‘adjacent_posts_rel_link’); } add_action(‘init’, ‘remove_header_info’); The default installation does not include stuff like meta keywords, so that is either a theme or plugin that you are … Read more

Categories post-meta Tags functions, headers, post-meta, seo

How do I save each option in a multiple select menu as it’s own meta_key + meta_value pair?

Try this inside save_post but please note the code is not tested $old = get_post_meta($post_id, ‘products’); $new = isset ( $_POST[‘products’] ) ? $_POST[‘products’] : array(); if ( empty ($new) ) { // no products selected: completely delete alla meta values for the post delete_post_meta($post_id, ‘products’); } else { $already = array(); if ( ! … Read more

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

Setting post meta data to random value during post status transition / on publish

Slight change in your code, function wpse_custom_field_on_publish( $new, $old, $post ) { // Only run on “from X > to publish”-transitions if ( $new === ‘publish’ && $old !== ‘publish’) { $page_views = get_post_meta( $post->ID, ‘post_views_count’, true ); // Only set ‘post_views_count’ post meta value if there is none so far if ( empty( $page_views … Read more

Categories posts Tags post-meta, post-status, posts
Older posts
Newer posts
← Previous Page1 … Page182 Page183 Page184 … 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