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

Display Yoast WordPress SEO title in archive template

Get Archive SEO titles If you defined a Custom Post Type archive title you can get that by: $titles = get_option( ‘wpseo_titles’ ); $title = $titles[‘title-ptarchive-POST_TYPE’]; echo apply_filters( ‘the_title’, $title ); Remember to replace POST_TYPE by your own Custom Post Type. To display all the wpseo_title variables, you can use: printf( ‘<pre>%s</pre>’, print_r( get_option( ‘wpseo_titles’ … Read more

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

WordPress is stripping escape backslashes from JSON strings in post_meta

Doesn’t look like there’s any way to avoid it. The update_metadata() function, which is ultimately responsible for saving the meta, explicitly runs a stripslashes_deep() on the meta value. This function will even strip slashes from array elements, if the value were an array. Theres a filter that’s run AFTER that called sanitize_meta, which you could … Read more

Categories post-meta Tags json, post-meta

How to save an array with one metakey in postmeta?

You don’t need to loop through the values. Just use update_post_meta($post_ID, {key}, {array of vals}), it should do! <?php $poddata = Array( ‘pod_id’ => $this->pod_id, ‘url’ => $this->url, ‘name’ => $this->name, ‘description’ => $this->description, ‘service’ => $this->service, ‘status’ =>$this->status, ‘price’ => $this->price ); //Update inserts a new entry if it doesn’t exist, updates otherwise update_post_meta($post_ID, … Read more

Categories post-meta Tags 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
Older posts
Newer posts
← Previous Page1 … Page200 Page201 Page202 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