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

Select from wp_post and multiple meta_value from wp_postmeta

You need to join the post_meta table twice to the posts table, once for each meta value: SELECT p.ID id, p.post_title title, country.meta_value country, region.meta_value region FROM {$wpdb->posts} p JOIN {$wpdb->postmeta} country ON p.ID = country.post_id AND country.meta_key = ‘search_country’ JOIN {$wpdb->postmeta} region ON p.ID = region.post_id AND region.meta_key = ‘search_region’ WHERE p.post_status=”publish” AND p.post_type=”films” … Read more

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

wp_insert_post bulk import 500 server error

My advice is to not do long running bulk-operations over a web-connection in the first place. PHP works just fine from the command line. Write your one-time script to do whatever it is that you need it to do. If you need access to WordPress functions in that process, then include the wp-load.php file at … Read more

Categories wp-insert-post Tags bulk-import, post-meta, wp-config, wp-insert-post

Change post thumbnail using front end post edit form

it is much easier with WordPress inbuilt function media_handle_upload http://codex.wordpress.org/Function_Reference/media_handle_upload // These files need to be included as dependencies when on the front end. require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); require_once( ABSPATH . ‘wp-admin/includes/file.php’ ); require_once( ABSPATH . ‘wp-admin/includes/media.php’ ); // Let WordPress handle the upload. // Remember, ‘my_image_upload’ is the name of our file input … Read more

Categories post-thumbnails Tags post-meta, post-thumbnails

Act on user meta updated, but only once

If you can assume that user profile is edited all at once (Users Role, Organisation ID and Organisation name), you can hook on only one meta_key (say Organisation name) and send all infos at this moment. By the time this action is fired, all 3 metas are already in database. add_action(‘updated_user_meta’, ‘when_user_meta_updated’, 10, 3); function … Read more

Categories plugin-development Tags hooks, plugin-development, post-meta

Get meta info related to current post

The way you did in your code you are querying posts with the key rw_related_link. If I understood you right, you must use get_post_meta inside the loop. <?php while ($normal_query->have_posts()) { $normal_query->the_post(); $related_link = get_post_meta(get_the_ID(), ‘rw_related_link’, true); // The value you want is in $related_link variable. ?> <li><a href=”https://wordpress.stackexchange.com/questions/178321/<?php the_permalink(); ?>”><?php the_title(); ?></a></li> <?php } … Read more

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

Sorting and limitation with pre_get_posts

Before we code and go into particulars, lets look at the problem at hand. First of all, any valid date format is valid in a custom field if you are not going to use it for comparisons and sorting When you are going to sort by date or do comparisons by date in a custom … Read more

Categories filters Tags filters, post-meta, pre-get-posts, sort

How to get the total number of meta_values based on a custom post type?

There may not be a need for a custom query, but I’d recommend it rather than hitting the database: – once for the WP_Query – once more for each post entry And then manually working out the math in PHP. Do it all at once with one MySQL statement. select sum(PM.meta_value) from wp_postmeta PM join … Read more

Categories post-meta Tags meta-value, mysql, post-meta

Create a random unique 6 digit number as custom field for custom post type

This quite an expensive operation what you are doing, and IMHO wrong worksflow as well. What you want to do is, is the following Get all the meta_values from the specific meta_key you need. You can then check the random number against the values returned from a specific meta_key Here is a very basic idea … Read more

Categories custom-post-types Tags custom-field, custom-post-types, loop, php, post-meta

How to permanently delete a post meta entry?

delete_post_meta will delete the meta row. delete_post_meta also uses wpdb class to delete the meta rows. Can you show us the full code. For your information delete_post_meta executes the following mysql command DELETE FROM wp_postmeta WHERE meta_id IN( “85” ); through delete_metadata function. meta_id 85 is just given for example purpose. It is dynamic. so … Read more

Categories posts Tags post-meta, posts

WooCommerce: Adding Order Item Meta Data That’s Hidden

You’ll want to add to the hidden item meta array as such: add_filter(‘woocommerce_hidden_order_itemmeta’, array($this, ‘hidden_order_itemmeta’), 50); function hidden_order_itemmeta($args) { $args[] = ‘my_hidden_meta’; return $args; }

Categories woocommerce-offtopic Tags post-meta, underscore, woocommerce-offtopic
Older posts
Newer posts
← Previous Page1 … Page157 Page158 Page159 … Page204 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