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

WordPress retrieving meta data for all custom post types in list view

Try changing hierarchical: false in your CPT definition (if your application allows). When CPT’s are set to hierarchical: true all posts will be queried in the admin dashboard which can cause memory issues.

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

How to use update_{$meta_type}_metadata filter to modify meta value

The code snippet in question is: $check = apply_filters( “update_{$meta_type}_metadata”, null, $object_id, $meta_key, $meta_value, $prev_value ); if ( null !== $check ) return (bool) $check; This filter only allows you to prevent the updating of the metadata for a given type, not to explicitly change the metadata itself. If you want to use this filter … Read more

Categories filters Tags filters, post-meta

What’s the point of get_post_meta’s $single param?

In general, storing PHP serialized data in database in a bad idea. It can be easily understood if you use multple key-value pairs of data in one field row, that is, you use an array or a object with one meta key. Imaging a car as the object. You can set multiple meta values to … Read more

Categories post-meta Tags post-meta

How to enable revisions for post meta data?

I’m sorry, but for now there is no easy way to “enable” revisioning of postmeta. However, you can add post metadata to revisions. A guy named John Blackburn wrote a pretty good article about adding post metadata to revisions. You find it here: https://johnblackbourn.com/post-meta-revisions-wordpress

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

Filtering posts by post meta data

The WP_Query object accepts a post meta argument. Generally speaking you want to do the following: $my_query = new WP_Query( array( ‘post_type’ => ‘post’, ‘meta_query’ => array( array( ‘key’ => ‘project_cat’, ‘value’ => ‘my-value’, ) ), // Other query properties ) ); Where ‘my-value’ is your ‘specified value’. Example usage: add_action( ‘pre_get_posts’ , ‘my_pre_get_posts’ ); … Read more

Categories query-posts Tags post-meta, query-posts

Adding meta tag without plugin

Although I would advice you to avoid this and use a plugin for this work. Because only a dedicated plugin can help SEO. “WordPress SEO” from yoost is a great plugin for SEO. That being said, here is the code for adding meta description and keywords in header. Paste this in theme’s functions.php file. function … Read more

Categories post-meta Tags post-meta, seo

How to add category to: ‘wp-admin/post-new.php’?

Dave James Miller over at GitHub nailed this one for me. None of the work is from me, I’m just posting his code wrapped into a plguin since it works perfectly as advertised: <?php /** * Plugin Name: Set default category from url parameter * Plugin URI: https://gist.github.com/davejamesmiller/1966543 * Description: enables you to setup new … Read more

Categories posts Tags categories, post-meta, posts, rest-api, urls

How to update_post_meta value as array

You do this: $item->content_multiple = get_post_meta($item->ID, ‘_menu_item_content_multiple’, true); Note how you set the third parameter of get_post_meta() to true, which means that only one value will be returned. If you read the docs, you will see that, if the third parameter is false, you will get an array with all the values for that meta … Read more

Categories post-meta Tags post-meta

How to hook a filter to catch get_post_meta when alternate a custom field output?

After a lot of messing around with this, I think I found a fairly good solution here. I realize this is over a year after you asked but this was bothering me and I couldn’t find a good solution until now. The problem is that the get_post_metadata function doesn’t allow you to access the current … Read more

Categories filters Tags filters, post-meta

What is “meta_input” parameter in wp_insert_post() used for?

This part of wp_insert_posts() gives it away: if ( ! empty( $postarr[‘meta_input’] ) ) { foreach ( $postarr[‘meta_input’] as $field => $value ) { update_post_meta( $post_ID, $field, $value ); } } where we see how the post meta fields are updated/added with update_post_meta(). Here’s the inline description for meta_input: Array of post meta values keyed … Read more

Categories custom-field Tags custom-field, post-meta, wp-insert-post
Older posts
Newer posts
← Previous Page1 … Page199 Page200 Page201 … 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