Questions tagged [meta-value]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
32 votes
5 answers
53k views

Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title

I'm working on a custom taxonomy term page template where we want the items that are connected to the term sorted by a publication date (custom date field) - and if there are multiple items on the ...
CSSgirl's user avatar
  • 746
51 votes
10 answers
112k views

How to only display posts whose meta_value field is not empty?

Three people have already tried to solve this, and we're coming up nil. I want to show only posts that have a value in the meta_key 'featured_image'. So... if 'featured_image' is not empty, show the ...
robalan's user avatar
  • 747
2 votes
1 answer
3k views

How to get user_meta value for new user regsitered?

We have a customized the registration process. Users register themselves. When a user registers, some meta values are updated based on the $user_id. Now we need to send an email. We have used action ...
Momin's user avatar
  • 23
1 vote
1 answer
10k views

Assign/update the custom field value for all posts

I have over 1000 posts. Each post has a custom field XYZ. I'm looking for a function that I can run once that will assign a value of 1 to each of the posts' custom field XYZ. I've had a look at this ...
Pete's user avatar
  • 998
1 vote
2 answers
1k views

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'...
Squiggs.'s user avatar
  • 123
0 votes
3 answers
27k views

Order by custom field date with ASC order

I've found several similar question but none of them explains why the below is giving me nothing with ASC order. It works with DESC. Basically it's a query that should list posts where the custom ...
elbatron's user avatar
  • 405
6 votes
4 answers
14k views

SELECT max(meta_value) FROM wp_postmeta WHERE meta_key='price'... stops working when value is over 999

Overview: I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts... just the value itself. Details: I have added a custom meta_key "...
Kirkland's user avatar
  • 298
2 votes
1 answer
33k views

Using get_terms() with meta_query parameters

Im trying to build a taxonomy query to only display the terms that have a certain custom field value assigned to it. The custom field holds a boolean value, so I tried: $args = array( '...
Luis Martins's user avatar
2 votes
1 answer
3k views

WordPress Admin Panel search posts with custom post meta values along with title

Trying to modify default admin search by including search by custom post type fields, Below is my code, function custom_search_query( $query ) { $custom_fields = array( // put all the ...
Vin_fugen's user avatar
  • 219
1 vote
1 answer
249 views

How to break meta values into different items and avoid duplicates?

I'm trying to build a filter for a custom post type page. The custom post type has a metabox that allows inputting of different authors. I am displaying the post names in a dropdown like this, using ...
artist learning to code's user avatar
0 votes
1 answer
2k views

Help With issue on pre_get_posts filter in taxonomy

I create a function to filter the taxonomy query with this code add_action('pre_get_posts', 'custom_taxonomy_query'); $option_taxposts_per_page = get_option('tax_posts_per_page'); function ...
nonsensecreativity's user avatar
0 votes
1 answer
576 views

Sorting meta_value as integer doesn't work

This plugin uses the below chunk of code to print the top 10 highscores. But this doesn't get the list of top 10 scores sorted by meta_value in my WP install $scoreboard = new WP_User_Query( array( ...
Man_Pat's user avatar