Articles of meta value

Add a default meta_value to new posts

I have a page template that allows users to create and update posts from the front end. I also am using 2 plugins, 1 that allows the user to rate posts from 1-5 stars and another that allows them to favorite the posts. I also have a page to allows the user to toggle between […]

Query Multiple Meta Values and display only when it has both meta values

I’ve been stuck on a problem for a while now and I can’t seem to figure it out. I want to query posts and only display them if their 2 meta values checked contain the ones I have queried. For example: If a post had 123 and 321 then I want them to be displayed. […]

Query post order by post and desc not working

I have a query that displays post the order of the post 1 to 10 and front-end added: <?php print intval( $post->menu_order );?>º there shows 1º, 2º, 3º … 10º must reverse the display but keep the number of order to stay well 10º, 9º … 1º The post number 1, will remain the 1º […]

How to get the total number of meta_values based on a custom post type?

I need to display the total number of votes that have been made for a specific custom post type. Here’s an example of how the wp_postmeta table looks for these keys/values: meta_id post_id meta_key meta_value 22 4 vote 4 26 6 vote 0 27 7 vote 1 32 10 vote 10 Suppose the first and […]

order by multiple meta_keys?

Hi i’d like to order by multiple meta_keys want to make it order using these keys adminscore + user_like + _count-views_all + comment_count combine these keys how should i array order it?? i try this but not work.. $args = array( ‘meta_key’ => ‘adminscore’ + ‘user_like’ + ‘_count-views_all’ + ‘comment_count’, ‘numberposts’ => $number_posts, ‘post_status’ => […]

Multiple Values stored as array in Meta Query

I’m a little confused as to best practise for saving multi-select values in meta fields. Assuming <select multiple name=”_casestudypost[]”> is my form field if I store $_POST[‘_casestudypost’] in a meta_key of the same name? (which returns an array) – how can I find out when 281 is in that array. I’ve tried: $args = array( […]

Individual post. Meta_key, taxonomy or post status for separation?

I have a posts with custom type – TOUR. Among ordinary Tours sometimes I need to create “personal” or “private” Tour, which will be shown only to assigned user. What the way is better to exclude this “private” Tour from others and not show it in the Tours list. Threre are meta_value, taxonomy or post_status […]

Custom WP Query from meta_value stored as serialised array

I’m using a Magic Fields 2 multicheck box to store Services which can be assigned to Case Studies. The data is stored as a serialised array in WordPress, and I need some help to extract the “related posts”. I know that you can’t simply use the array as the meta_value (WordPress simply doesn’t support it) […]

Job of meta_key meta_value fields in database tables

I’m researching the structure of WordPress database and there is something that really get me confuesd. Could someone please explain, what is the exact job of meta_key and meta_value fields in wp_commentmeta, wp_postmeta, wp_usermeta tables? What is the job of these tables anyway? I did read the Database Description in the Codex, but still don’t […]

WP_query : meta_key with custom rule for specific value

I’m a bit stuck with a WP_Query code. Here it is : $args = array( ‘post_type’ => ‘post’, ‘meta_query’=> array( ‘key’ => ‘karma’, ‘compare’ => ‘>=’, ‘value’ => 0, ‘type’ => ‘numeric’), ‘posts_per_page’ => 9, ‘meta_key’ => ‘karma’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘post__not_in’ => $dont_show_me ); What I want to do : Show […]