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

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

Custom Post type – how to get checkbox to update meta field to null

It appears the post meta is not being cleared for ‘sunday’ when the checkbox is unchecked. If( isset($_POST[‘sunday’]) ){ update_post_meta($post->ID, “sunday”, $_POST[“sunday”] ); }else{ delete_post_meta($post->ID, “sunday”); } return $post; Or you can set the value to false If( isset($_POST[‘sunday’]) ){ update_post_meta($post->ID, “sunday”, true ); }else{ update_post_meta($post->ID, “sunday”, false ); } return $post;

Categories custom-post-types Tags custom-post-types, 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

Is there a way to extend WP_query so Custom Post Types can have properties?

Getting meta data from a WP_Post object is already possible. Just write: echo $post->your_meta_key; This will call get_post_meta( $this->ID, $your_meta_key, true ) behind the scenes. See the documentation and the source code for WP_Post. This works also with instances of WP_User, but not with WP_Comment as far as I know. Don’t forget to escape the … Read more

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

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

Echo all meta keys of a custom-post TYPE

You can use a simple query to get a distinct list of user-entered meta_keys for a specific post type, then cache the results using the Transients API. The meta keys from this query will be those that do not start with an underscore or number. function generate_foods_meta_keys(){ global $wpdb; $post_type=”foods”; $query = ” SELECT DISTINCT($wpdb->postmeta.meta_key) … Read more

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

How to allow hidden custom fields to be added from wp-admin/post.php?

I found the following filter, here unlocking all protected meta data: add_filter( ‘is_protected_meta’, ‘__return_false’ ); Or it can be fine tuned: add_filter( ‘is_protected_meta’, function( $protected, $meta_key, $meta_type ) { $allowed = array( ‘_edit_lock’, ‘_test’, ‘_wp_page_template’ ); if( in_array( $meta_key, $allowed ) ) return false; return $protected; }, 10, 3 ); It allows to display the … Read more

Categories posts Tags post-meta, posts

Get meta_id along with meta_key and meta_value

This function worked for me: function get_complete_meta( $post_id, $meta_key ) { global $wpdb; $mid = $wpdb->get_results( $wpdb->prepare(“SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s”, $post_id, $meta_key) ); if( $mid != ” ) return $mid; return false; } it will return an array of objects like: Array ( [0] => stdClass Object … Read more

Categories PHP Tags php, 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

Admin Area Custom Type Search By Meta Fields Without Title & Content

There is a plugin called Search everything, where you can break down what you want to search. It does custom fields, posts and of course titles.

Categories custom-post-types Tags admin, custom-field, custom-post-types, post-meta, search
Older posts
Newer posts
← Previous Page1 … Page194 Page195 Page196 … 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