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

get_post_meta returning empty string when data shows in the database

Edit Invalid Answer The answer below is invalid as get_the_id() and get_the_ID() both return the required ID of the post inside the Loop. Thanks to @Jess_Pinkman for pointing it out. Your code should be working fine, but the only issue is you are using an incorrect function to get the ID of the post inside … Read more

Categories post-meta Tags post-meta

Restrict post edit/delete based on user ID and custom field

Through a lot more research and some trial and error, I figured out the correct code to use that will restrict a post from being edited based on the user ID AND a custom meta field. $user = get_current_user_id(); $super_users = array(1); The first two pieces of code within the function are important for restricting … Read more

Categories post-meta Tags actions, content-restriction, post-meta

How to update/insert custom field(post meta) data with wordpress REST API?

I just ran a test with your code and in my opinion, this is not working because you have an error in the get_callback function. First time it will try to get the subtitle( or the timing_of_experience) but it will trigger an error because it doesn’t exists in the first place and this error will … Read more

Categories post-meta Tags post-meta, wp-api

Trying to get custom post meta through Jetpack JSON API [closed]

From the documentation: According to the JetPack JSON API docs: By default, all metadata keys are allowed in the API, as long as they are not protected keys. Any metadata key that starts with _ is by default protected. Protected metadata keys can, however, be accessed and edited by users with the edit_post_meta (used for … Read more

Categories post-meta Tags api, json, plugin-jetpack, post-meta

Meta compare with date (stored as string) not working

Introducing STR_TO_DATE MySQL has a STR_TO_DATE function that you could leverage for the scope. To use it you need to filter the WHERE clause of a WP_Query, probably using posts_where filter. That function allows to format a column value as a date by using a specific format. By default, WordPress uses the CAST MySQL function … Read more

Categories post-meta Tags meta-query, 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
Older posts
Newer posts
← Previous Page1 … Page47 Page48 Page49 … 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