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

Content hooks vs User hooks

It depends on what exact action you are using, and what the purpose of that action is. For the update actions, for example, there should always be hooks that are triggered before doing the change (so that you may change or prevent it), and hooks that are triggered after the change has been completed (so … Read more

Categories post-meta Tags actions, post-meta, user-meta

update_post_meta not saving when value is zero

update_post_meta() calls update_metadata which begins with this line: if ( !$meta_type || !$meta_key ) return false; I wrote a simple test (with a lot of cut & paste) to see how string values of 0 are evaluated (instead of looking it up in the PHP manual): <?php $meta_key = (string) 0; if ( ! $meta_key … Read more

Categories post-meta Tags post-meta

advanced custom fields update_field for field type: Taxonomy

I do need to add both post_meta: add_post_meta( $insert_q_key_id, ‘q_key_type’, (int)$q_key_type ); // Q Key Type And for ACF: update_field( “field_52c737a413e07″, (int)$q_key_type, $insert_q_key_id ); // Q Key Type And the rest of the answer “should” be covered by wp_set_object_terms: wp_set_object_terms( $insert_q_key_id, (int)$q_key_type, ‘q_key_type’, true ); However, this function is not fully available at the point … Read more

Categories post-meta Tags advanced-custom-fields, post-meta, wp-insert-post

Safe to delete blank postmeta?

You should be fine deleting empty custom fields. The main reason is, that get_post_meta( $id, ‘metakey’, true ) returns an empty string if the field is not set, so it is the same as having an empty record set. get_post_meta( $id, ‘metakey’, false ), returns an empty array if no value is set, so you … Read more

Categories post-meta Tags mysql, post-meta

What is the code to get the download link for a product in WooCommerce?

Here is the code to get the download link for a downloadable product in WooCommerce. $downloads = $product->get_downloads(); foreach( $downloads as $key => $each_download ) { echo ‘<a href=”‘.$each_download[“file”].'”>Download</a>’; }

Categories post-meta Tags post-meta, woocommerce-offtopic

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
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
  • 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