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

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

Get Advanced Custom Fields values before saving [closed]

Edit – This answer is no longer accurate for the current version of ACF, see their documentation Use the acf_save_post hook. function my_acf_save_post( $post_id ) { // vars $fields = false; // load from post if( isset($_POST[‘fields’]) ) { $fields = $_POST[‘fields’]; } // … } // run before ACF saves the $_POST[‘fields’] data add_action(‘acf_save_post’, … Read more

Categories post-meta Tags advanced-custom-fields, post-meta

I can’t set meta_key in my custom post type query

That’s because ‘meta_key’ and ‘meta_value’ are not public query vars. In other words, you can’t use them in URLs directly, nor should you. Instead, register a specific query var, like so: function register_my_qv() { global $wp; $wp->add_query_var( ‘my_qv’ ); } add_action( ‘init’, ‘register_my_qv’ ); Then, you can go to a URL like this: ?my_qv=foobar All … Read more

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

Custom Post Type: Set post_title equal to a custom post type field

I would simply filter the_title so that it outputs the appropriate custom-field data for your custom post type: <?php function theme_slug_filter_the_title( $title ) { global $post; if ( ’employee’ == get_post_type( $post ) ) { $custom = ( get_post_custom( $post->ID ) ? get_post_custom( $post->ID ) : false ); $custom_title = ( isset( $custom[‘name’][0] ) ? … Read more

Categories custom-post-types Tags custom-post-types, post-meta

Save both current and new version of post meta

that could be caused by post revision being saved, and you should use wp_insert_post_data anytime you want to do something before the post is saved, here is an example plugin i just cooked up to test it and it looks like this: <?php /* Plugin Name: wpse37901 Plugin URI: http://en.bainternet.info Description: answer to http://wordpress.stackexchange.com/questions/37901/save-both-current-and-new-version-of-post-meta Version: … Read more

Categories post-meta Tags duplicates, post-meta

Query between two meta values?

Edited again to demonstrate adding and removing filters: Include these general functions in your functions.php. These are the filters you will invoke for the loops where you want to limit your query by these two meta values: function date_check_join( $join ) { global $wpdb; $join .= ” JOIN “.$wpdb->postmeta.” AS startdate ON (“.$wpdb->posts.”.ID = startdate.post_id … Read more

Categories post-meta Tags date-time, post-meta, sql

WP_Query not working as expected for attachments and custom meta_query

First, just pass your arguments to the constructor of WP_Query as this is both cleaner, and the way you’re supposed to do it according to the Codex documentation of the class. You should be constructing things like this: $my_key_query_args = array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘meta_query’ => array( array( ‘key’ => ‘my_key’, ‘value’ … Read more

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

Front-end update_post_meta snippet displays white screen?

Change your nonce verify to actually verify and update post meta, else do nothing. But don’t use exit at the top of your template. // top of page if ( isset( $_POST[‘drw_inventory’] ) && wp_verify_nonce($_POST[‘drw_inventory’],’update_drw_postmeta’) ) { //if nonce check succeeds. global $post; $postid = $post->ID; $data = $_POST[‘priceone’]; update_post_meta($postid,’metakey’,$data); } // in single.php $priceone … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page182 Page183 Page184 … 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