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

How do I query for posts by partial meta key?

Unfortunately you cannot perform a meta_query using a LIKE comparison on the meta_key value when using WP_Query. I’ve been down this road… Instead you have a couple other options if you want to maintain like status relationships as post meta and not user meta and or meta in a custom table. Option 1 requires no … Read more

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

How to get custom post meta using REST API

$post in the callback function is an array, not an object. So you cannot use $post->id. Change it to $post[‘id’] and it should work: function slug_get_phone_number($post, $field_name, $request) { return get_post_meta($post[‘id’], ‘_phone’, true); } I recommend to change _phone to phone_number or something else without underscore prefix. Because _ is often used with private meta … Read more

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

Check if Post Title exists, Insert post if doesn’t, Add Incremental # to Meta if does

This would need a query. So building on your code: <?php $postTitle = $_POST[‘post_title’]; $submit = $_POST[‘submit’]; if(isset($submit)){ global $user_ID, $wpdb; $query = $wpdb->prepare( ‘SELECT ID FROM ‘ . $wpdb->posts . ‘ WHERE post_title = %s AND post_type = \’stuff\”, $postTitle ); $wpdb->query( $query ); if ( $wpdb->num_rows ) { $post_id = $wpdb->get_var( $query ); … Read more

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

Custom post meta field effect on the performance on the post

To answer this, I have gone and done some tests on this, and the results was actually mind blowing. Here is my test To this yourself, set yourself up with a test page. Just simply copy page.php, rename it and delete the loop. Now just create a new page in the back end. Before you … Read more

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

How to check if post meta key exists or not in wordpress database

In case anyone else stumbles across this old question like I just did, it looks like the best way to handle this is using metadata_exists() see https://developer.wordpress.org/reference/functions/metadata_exists/ Here’s what the syntax would be for post meta: metadata_exists(‘post’, $post_id, ‘meta_key_to_check’);

Categories posts Tags post-meta, posts

Why are simple updates to wp_postmeta’s “_edit_lock” so slow?

the _edit_lock is generated each time you edit a post or page. it consist the timecode and the user. so WordPress is knowing who is currently editing it. meta_id post_id meta_key meta_value 9 5 _edit_lock 1388386997:1 if you manipulate it WordPress reacts somehow sensitive …I tried to fetch how many seconds somebody worked on a … Read more

Categories MySQL Tags mysql, post-meta

How can I get the post ID from a WP_Query loop?

get_the_ID() can (only) be used within the loop. This retrieves the ID of the current post handled by the loop. You can use it on it’s own if you need it only once: $dish_meta = get_post_meta( get_the_ID(), ‘dish_meta’, true ); You can also store it as a variable if you need it more than once: … Read more

Categories post-meta Tags post-meta

Meta query with boolean true/false value

TL;DR: This problem probably mostly happens when a boolean field is created as optional. You can fix it either by making it required, or using a more complex query to retrieve the default case. More details: There are two data representation problems going on here: one is which data values are being used to represent … Read more

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

How to make search include data from wp_postmeta?

If your up for using a plugin, Relevanssi – A Better Search might be worth trying out. The standard (free) version supports searching post meta.

Categories search Tags post-meta, regex, search

Why WordPress choose data serialization over json_encode?

I think, not 100% sure that this was the real reason the WP developers took this approach, but common sense tells me that serialize preserves the variable types and have a mini built in error detection, and json stores only string values { key : value }, so when you go back to PHP you … Read more

Categories Database Tags database, post-meta
Older posts
Newer posts
← Previous Page1 … Page199 Page200 Page201 … 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