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 REST API “rest_no_route” when trying to update meta

Here is what I have learned about the WP REST API: It is a mess of undocumented and unfinished code with great promise but frustratingly little clarity. That said, I have a workaround that I will post here, hoping it is useful to others in a similar pickle to me: I just found that I … Read more

Categories post-meta Tags post-meta, rest-api

How to count post meta key values for all posts in database

You have a structural problem with your data. Serialized data in the database is terrible if you need to search over pieces of that serialized data. There is no reliable, efficient, and certainly no easy, SQL query to search over serialized data. “serialization” is a PHP mechanism. It isn’t SQL. To the database that is … Read more

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

update_post_meta() not working in save_post

You aren’t retrieving the saved data and populating the form. function swpd_render_info_fields() { ?> <label for=”swpd_comany_addr”>Company Address</label> <input type=”text” name=”swpd_company_addr” id=”swpd_company_addr” /> <?php } There is nothing in that function that would insert your saved data. You just write a blank form every time. You need to be conditionally populating the input value. function swpd_render_info_fields($post) … Read more

Categories save-post Tags post-meta, save-post

Documentation for post meta

There is no official documented list of all possible post meta keys in core. The closest I could for anything unofficial was this answer on Stack Exchange: You probably don’t want to use the following post meta keys: _thumbnail_id – Used to store the featured image ID _edit_last – Used by the Heartbeat API _edit_lock … Read more

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

Compare 3 custom fields and sort by oldest

While the query you describe is not impossible in SQL, it is not going to be very efficient as the query would have to evaluate every row in the table matching those keys, and then sort based on the result of the calculation. You are better saving a fourth value and sorting on that, as … Read more

Categories custom-post-types Tags custom-post-type-archives, custom-post-types, order, post-meta

Is it possible to sort the post based on a custom field?

Yes, You can call action “pre_get_posts”. add_action(‘pre_get_posts’,’search_filter’); You can add parameter : $args = array( ‘post_status’ => ‘publish’, ‘posts_per_page’ => 6, ‘paged’ => $paged, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); You can use above parameter e.g. : function search_filter($query){ if ( !is_admin() && $query->is_main_query() ) { $query->set(‘post_status’, ‘publish’); $query->set(‘meta_key’, ‘event_date’); $query->set(‘orderby’, … Read more

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

How to get meta value in wp_attachment_metadata

There are two methods: get_post_meta() $attachment_meta = get_post_meta( $post->ID, ‘_wp_attachment_meta’, true ); Will return an array(): $width = $attachment_meta[‘width’]; That true as the third parameter is especially important in this case, since the metadata being queried is a serialized array. You need to return it as single, or you’re going to get an array returned, … Read more

Categories post-meta Tags attachments, images, post-meta

Give extra post-meta to RSS feeds

WordPress uses SimplePie for reading feeds, not for generating feeds. You’re looking at two different things here: You want to output your custom post meta in an RSS feed. You want to read that custom post meta somewhere else. The first part is pretty easy. WordPress supports custom RSS feed templates. You can actually replace … Read more

Categories post-meta Tags post-meta, rss, simplepie

Better post meta efficiency?

If you need to search by your meta_key/meta_value then do not store them in a single key. If you store as a single key then you are going to have to store your data as serialized string, or something similar. The only way you can search that would be via an inefficient %LIKE% query which … Read more

Categories posts Tags custom-field, hooks, post-meta, posts, save-post

Grossly inefficient wordpress loops!

You could do it with one loop, you just need a valid sort order right? Players with one instrument, followed by the next and so on.. UPDATE: Following on the asker’s comment, you can still use one query and use rewind_posts() to iterate the loop as many times as you need, ie. do something like … Read more

Categories custom-post-types Tags custom-post-types, loop, post-meta
Older posts
Newer posts
← Previous Page1 … Page183 Page184 Page185 … 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