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 posts by meta value with date

Depends what you are getting back from the ‘date_event’ post-meta field. That’s probably the culprit here — if it’s an actual date with a month and day, it’s not going to match what you are getting from date(‘Y’), which is just going to be ‘2018’. You can check the value in ‘date_event’ on any of … Read more

Categories post-meta Tags date, get-posts, post-meta

How to filter into post meta data before saving

The add_post_metadata and update_post_metadata filters are meant to allow filtering whether a specific meta data should be saved (added/updated) or not, only. The default value (of $check) is a null, and if you return anything other than exactly null (i.e. !== null), the meta data will not be saved (into the database). However, the add_metadata() … Read more

Categories filters Tags filters, post-meta

loop through all meta keys with get_post_meta

As @Sally CJ noted in the comment to your question, you should just omit the meta key: $meta = get_post_meta( $post->ID, ”, true ); echo $meta[‘car_year’]; // 2005 In PHP 7.1 you can use array destructing: [ ‘image_meta’ => $image_meta, ‘car_year’ => $car_year, ‘car_mileage’ => $car_mileage, ‘car_price’ => $car_price, ‘car_model’ => $car_model, ] = get_post_meta( … Read more

Categories post-meta Tags 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
Older posts
Newer posts
← Previous Page1 … Page170 Page171 Page172 … 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