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 get post id from meta value

Try this. It will work. $prepare_guery = $wpdb->prepare( “SELECT post_id FROM $wpdp->posts where meta_key =’_Wps_crossells’ and meta_value like ‘%%d%'”, $meta_value ); $get_values = $wpdb->get_col( $prepare_guery ); Let me know it’s working or not.

Categories post-meta Tags post-meta

How we get_post_meta without post id

$post->ID is what makes the meta value distinguished across all posts with the same meta key. So if you want to shorthand the get_post_meta call for the current post you can do this: function get_cuurent_post_meta($key){ global $post; return get_post_meta($post->ID,$key,true); } and you can call it like this: echo get_cuurent_post_meta(‘custom_tags’.$userID); Now if its not the current … Read more

Categories post-meta Tags post-meta

if get_post_meta is empty do something

You could use the empty function inside your if as such : <?php if( empty( get_post_meta( $post->ID, ‘price_list_category1’, true ) ) ) : ?>style=”display:none;”<?php endif; ?> The above returns an error, you should assign the return value to a variable. See my edit below. Warning empty might not be the best option depending on the … Read more

Categories post-meta Tags post-meta

Get a single post by a unique meta value

I am just incredible stupid here as this can be easily done by a simple WP_Query: new WP_Query( array( ‘post_type’ => ‘shop_order’, ‘meta_key’ => $meta_key, ‘meta_value’ => $meta_value ) ) However, I decided to compare the actual generated SQL of the get_posts() with a ‘post_where’ filter solution which is: SELECT wp_posts.ID FROM wp_posts WHERE 1=1 … Read more

Categories post-meta Tags post-meta

Lack of composite indexes for meta tables

A standard WordPress schema “sync” via dbDelta() will only add indexes, not drop them. Same goes for fields. We never touch the storage schema either, so it’d be the default for MySQL (which in latest versions is now InnoDB). On the face, a comment_id_meta_key index makes perfect sense. But when you look at how WordPress … Read more

Categories post-meta Tags comment-meta, mysql, post-meta

Execute action after post is saved with all related post_meta records (data)

For NEW post type ‘post’ use draft_to_publish action hook: function fpw_post_info( $post ) { if ( ‘post’ == $post->post_type ) { // echo ‘<pre>’; print_r( $post ); echo ‘<br />’; // $meta = get_post_meta( $post->ID ); print_r( $meta ); echo ‘</pre>’; die(); // your custom code goes here… } } add_action( ‘draft_to_publish’, ‘fpw_post_info’, 10, 1 … Read more

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

post formats – how to switch meta boxes when changing format?

I did something like this once, but when you clicked on a certain category (essentially the same) It certainly isn’t a true ajax solution, it just hides and reveals the div with the settings, but It is a solution which works. You’ll definitely have to modify this for your needs, but if you have a … Read more

Categories post-meta Tags ajax, metabox, post-formats, post-meta

Sanitizing integer input for update_post_meta

For integers KSES has no special function. Use (int) or intval() or absint() See more: Data Validation – Integers

Categories post-meta Tags input, post-meta, sanitization

How to edit a post meta data in a Gutenberg Block?

Think I found the answer here. The first argument to register_meta is not post type but object_type, which is in my case should be post rather than taxonomy or comment. The function description, found here, states as of WordPress 4.9.2 the correct parameter is post. Once I switched it everything worked. register_meta(‘post’, ‘event_location’, [ ‘show_in_rest’ … Read more

Categories post-meta Tags block-editor, post-meta

What is the different between an attachment in wp_posts and an attachment in wp_postmeta?

An attachment is a Post The posts table contains information on the attachment post. In WordPress every uploaded media has it’s own post entry, where post_type is ‘attachment’ and post_status is ‘inherit’. In fact, you can get attachment post types using functions used to get other post types, like post, page or any CPT. That … Read more

Categories post-meta Tags attachments, post-meta, woocommerce-offtopic
Older posts
Newer posts
← Previous Page1 … Page48 Page49 Page50 Page51 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