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

Add “upload media” button in meta box field

See this media uploader skeleton. You can also use it in your custom markup, like Meta Box. A hint, check, that you only use the scripts on the page, where you active your Meta Box. Otherwise is it often a problem on the default pages and the uploader. Now a attempt to clear the important … Read more

Categories metabox Tags media, metabox, post-meta, uploads

Passing error/warning messages from a meta box to “admin_notices”

You can do this by hand, but WP natively does it like this for settings errors: add_settings_error() to create message. Then set_transient(‘settings_errors’, get_settings_errors(), 30); settings_errors() in admin_notices hook to display (will need to hook for non-settings screens).

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

Attaching taxonomy data to post with wp_insert_post

Use wp_set_object_terms after you have the post id for each taxonomy: … $post_id = wp_insert_post( $my_post ); wp_set_object_terms( $post_id, $location, ‘location’ ); wp_set_object_terms( $post_id, $sale_rental, ‘sale_rental’ ); wp_set_object_terms( $post_id, $price, ‘price’ );

Categories taxonomy Tags customization, post-meta, taxonomy, wp-insert-post

order by numeric value for meta value

you need to use ‘orderby’ => ‘meta_value_num’, also if you are ordering dates, the best advice is to put them in an easy to order way such as 2012-12-31

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

Can wp_query return posts meta in a single request?

By default, WP_Query returns the standard WP_Post objects for the posts being queried. I believe with some clever rewrite and use of the filters given in WP_Query you can add objects to the returned WP_Post objects array. Will this be performant? In my opinion, it will hurt performance more as you will need to join … Read more

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

How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]

Add the following code in the archive template loop to display Yoast SEO meta description for each post. echo get_post_meta(get_the_ID(), ‘_yoast_wpseo_metadesc’, true);

Categories loop Tags loop, plugin-wp-seo-yoast, post-meta

How to update custom fields using the wp_insert_post() function?

If you read the documentation for wp_insert_post, it returns the post ID of the post you just created. If you combine that with the following function __update_post_meta (a custom function I acquired from this site and adapted a bit) /** * Updates post meta for a post. It also automatically deletes or adds the value … Read more

Categories PHP Tags custom-field, php, post-meta, posts, wp-insert-post

Advanced search form with filters for custom taxonomies and custom fields

I think something like this you would be best writing yourself. Take a look at: http://www.catalysthomes.co.uk/homes-for-sale/ Properties are loaded into a CPT and I have my own custom search in the sidebar. Of that search its searching a number of things such as taxonomies, custom fields and ordering by date price etc. So how do … Read more

Categories custom-post-types Tags custom-field, custom-post-types, custom-taxonomy, post-meta, search

Post meta vs separate database tables

Well, if I take the hat of a WP script kiddie, my answer would be: use post_meta, always. However, I happen to know a thing or two about databases, so my answer is: never, ever, ever, use an EAV (aka the post_meta table) to store data that you might to need to query. On the … Read more

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

Can I exclude a post by meta key using pre_get_posts function?

I see many people prefer to use pre_get_posts hook instead of query_posts Yay! So pre_get_posts filters a WP_Query object which means anything you could do via query_posts() you can do via $query->set() and $query->get(). In particular we can make use of the meta_query attribute (see Codex): $meta_query = array( array( ‘key’=>’featured’, ‘value’=>’yes’, ‘compare’=>’!=’, ), ); … Read more

Categories custom-field Tags custom-field, featured-post, post-meta, pre-get-posts
Older posts
Newer posts
← Previous Page1 … Page202 Page203 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