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

WP_Query, custom sort and custom filter

Did you try something like this: $loop = new WP_Query( array( ‘post_type’ => ‘business_club’, ‘meta_value’ => ‘United Kingdom’, ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘zone’ ) ); while ( $loop->have_posts() ) : $loop->the_post(); I don’t know yet if you can do the then orderby town and title.

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

How to store multiple input values with same meta_key

Change your form as suggested: function startdate() { global $post; $custom = get_post_custom($post->ID); echo “<label>Startdates</label><br/>”; for ($i=0; $i<count($custom[“startdate”]);$i++) { echo “<input type=\”text\” name=\”startdate[“.$i.”]\” value=\””.$custom[“startdate”][$i].”\” />”; } } You’ll have to remove and reinstate your individual postmeta entries: add_action(‘save_post’, ‘save_details’); function save_details($post_id) { if ($parent_id = wp_is_post_revision($post_id)) $post_id = $parent_id; if (!empty($_POST[‘startdate’]) && is_array($_POST[‘startdate’])) { delete_post_meta($post_id, … Read more

Categories metabox Tags metabox, post-meta

update_post_meta not adding anything.(Nor add_post_meta)

Found the solution in this post: update_post_meta and update_field ony working when saving the post The solution is to use update_field because update_post_meta uses a different method to update fields than ACF does. Do note that this is the correct order of using the code update_field($meta_key, $meta_value, $post_ID);.

Categories post-meta Tags post-meta

Best approach to create Hot and Trending sections

In my personal opinion, this can get a bit resource intensive, so you will need to implement some type of cache system, or even look at transient What you want to do is to extent your current post view function or even create one on the side for this. You would want to capture each … Read more

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

Add a post meta key and value only if it does not exist on the post

It looks like you need to use update_post_meta() https://codex.wordpress.org/Function_Reference/update_post_meta Source: WP Codex The function update_post_meta() updates the value of an existing meta key (custom field) for the specified post. This may be used in place of add_post_meta() function. The first thing this function will do is make sure that $meta_key already exists on $post_id. If … Read more

Categories custom-field Tags custom-field, post-meta

Does WP get all post_meta on POST page?

One call to get_post_meta() fetches all met keys and values for that post. All these values are then stored in the cache. The next call will just fetch the data from the cache. So you can safely call that function multiple times. In details: get_post_meta() calls get_metadata(‘post’, $post_id, $key, $single); get_metadata() checks the cache and … Read more

Categories posts Tags post-meta, posts

How to get custom field image url of specific size

The get_post_meta() function can help to get the meta field but will not retrieve different size. Assuming _pf_photo1 embed the attachment id, you can do something like that: // Note the “_id” suffix $attachment_id = get_post_meta($post->ID, ‘_pf_photo1_id’, true); Last parameter for this function can not be ‘medium’, Now,you can use $attachment_id with different function depending … Read more

Categories plugins Tags attachments, custom-field, plugins, post-meta

Adding meta data to an attachment post

So since attachments are post types, you should be able to assign them postmeta like any other post type. Using the update_post_meta function should get you where you need to be. update_post_meta( $attachment_id, ‘price’, $price ); http://codex.wordpress.org/Function_Reference/update_post_meta Then run your query based on a meta key. $args = array( ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, … Read more

Categories post-meta Tags attachments, post-meta

get_post_custom()

What qualifies as custom field? Yes, a custom field is equal to post metadata, but be aware that some metadata is only for internal use (usually prepended with an underscore, for example _edit_lock. A more detailed look at the function The function get_post_custom() is actually just a wrapper for get_post_meta(): (wp-includes/post.php line 1764), but with … Read more

Categories post-meta Tags post-meta

Triple meta_key on custom SELECT query

Your Query is incorrect. To retrive meta values for triple meta_key you will need 3 different joins using posts meta on posts table. Check code below: // Example value $user_id = 1; // Calculate average post rating for user $ratings_query = $wpdb->get_results( $wpdb->prepare(” SELECT pmeta.meta_value FROM wp_posts LEFT JOIN $wpdb->postmeta AS pmeta ON (pmeta.post_id = … Read more

Categories post-meta Tags mysql, post-meta, select, wpdb
Older posts
Newer posts
← Previous Page1 … Page172 Page173 Page174 … 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