The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
28 views

How to sort category by custom field value

I am using the following : $catargs = array( 'meta_key'=> 'category_custom_order', 'orderby' => 'meta_value_num', 'order'=> 'ASC', ); but I can get the ...
0
votes
1answer
18 views

how to query for meta_value have array

I have array in post_meta like this: array( 'option1' => 'true', 'option2' => 'true', 'option3' => 'false', option4' => 'true', 'option5' => 'false' ) and I would ...
0
votes
1answer
27 views

Show posts of an advanced search form

I have created a search form with multiple fields, and I want to display the posts that match all the fields inserted in the search form. For example, if I choose T-shirt && Red && L, ...
0
votes
0answers
24 views

Need help with meta_value sorting custom posts

Basically, every custom post (butik) has alternative buttons (butik, restaurang, cafe, service) in the edit mode. This code I'm using now worked when I had select buttons where only 1 category could ...
0
votes
0answers
18 views

Filter to order Admin Custom Post List makes template query come up empty

In my template I query the posts like so: query_posts(array( 'post_type' => 'homeslide', 'meta_key' => 'slide_order', 'orderby' ...
0
votes
1answer
74 views

Get an array of meta_values for a user meta_key

I need to get an array of all the meta_values for a user meta_key. I found this code: $cities = $wpdb->get_col("SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = 'my_cities_meta_key'" ); ...
0
votes
1answer
102 views

How to delete only user meta value (not key) from usermeta table in wordpress?

I store multiple image in media library and save its id in wp_usermeta table. my metakey is 'images' and meta value in like '279,280,281'. Now I get the image from table like this: <?php $images = ...
0
votes
0answers
78 views

Sorting Posts with meta value not working

I want to retrieve most popular posts based on 'view_count' meta value, the below code doesn't seem to work, I am getting some random posts, where am I doing it wrong? <?php ...
0
votes
0answers
34 views

Make a button change meta_value

I would like if someone could point me in the right direction for doing this. Each post frontend should have a button that changes the database value on/off if the user is logged in. Ie.: post_id: ...
1
vote
0answers
81 views

Sort alphabetically by custom field

I'm trying to change the sort order of a custom field in a custom post type. I want it to be be alphabetical by the 'location' name. It's sorting by location, but not keeping them in alphabetical ...
0
votes
1answer
40 views

Want to order by Meta Values (tweaking Post Order Widget)

I'm not much of a coder, but I can tweak PHP a bit. Basically I want to order by a custom meta value which integer called "price". The plugin orders by title, so thats what I'm changing to price, ...
0
votes
0answers
20 views

orderby multiple meta keys and meta values

In wordpress, I have posts with meta key "country" and meta values: "usa", "france", "spain", "venezuela" etc... I have the same posts with meta key "rating" and meta values from "1" to "10" I would ...
0
votes
0answers
58 views

meta_key meta_value - post count

I have code written by Johannes Pille. How to change values of text retrieved from the database at the pictures? e.g. if($value == 'x') { echo '<img src="x.png" title="" alt="" />'; } ...
0
votes
1answer
342 views

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 ...
1
vote
2answers
194 views

Add meta value to custom post type on publish

I have a client who is requesting that all posts of a certain custom post type (called 'custom-jobs') be set to automatically be included in the sitemap in the Yoast SEO plugin. I found that in ...
0
votes
1answer
94 views

How do i get value from wp_postmeta?

I am trying to get a specific value from wp_postmeta, I'm aware about meta_key and meta_value. Problem is Meta value stores lots of values and i want specific value. Here's the value in the ...
0
votes
1answer
64 views

Cannot order by in WP_Query

I'm stuck with this issue : I'm having a custom query in which I cannot order by anything. I want to order by a specific meta_value. But event when ordering by name, title, date etc, I still can't. ...
1
vote
1answer
565 views

Sort Order for a Custom Query in a Post Type Archive Not Working

I have a custom post type for events set up and am displaying the posts in a custom post type archive "archive-events.php". I am using Advanced Custom Fields to put an event date "event_date" on ...
1
vote
2answers
203 views

Meta Query relation “AND” then set array accordingly

I have a search form on my home page that sets up the url query_string accordingly for the code below. When I use or I get results. However when I used "AND" for the relation I dont get any results ...
0
votes
1answer
91 views

Wordpress loop based on url sting

I have a search form on my home page that contains ACF custom fields values in the dropdowns. On submit the form goes to /test-results/. On the form I have dropdowns for Price, Region and Title. If ...
0
votes
1answer
140 views

Order by meta value pro first then meta value free in my search function

My meta key is geo_listing_type and this key have 2 meta_value, pro and free. I want to order these by pro first then free <?php get_header(); ?> <!--Start Content Wrapper--> <div ...
0
votes
1answer
188 views

Meta query with compare by more than 2 fields

i have 5 sets of meta boxes in some custom postype. So.. i know how to compare two meta box values... Example: 'meta_query' => array( 'relation' => 'AND', array( 'key' ...
0
votes
1answer
87 views

Does meta_query working with value paramater higher then 999?

I am trying to get posts by price using query_post() function. Price must be in range between two values. This I made using meta_query. But when I cant get posts when right value higher then 999 in ...
1
vote
1answer
376 views

Ordering by meta_value AND date NOT WORKING with wp_query

I want to select posts and custom post type with a specific meta value (mb_home!=0), of last week and ORDER them by mb_home. If they have the same mb_home value, I want them to be ordered by date. ...
0
votes
0answers
55 views

Query to select specific users is not returning any users

I use wordpress and have the following query to select specific users, but the query is not showing any users when running it put together. global $wpdb; $date2day = date("d-m-Y"); ...
0
votes
1answer
48 views

Automatically delete posts based on query

I'm trying to delete certain posts (of a custom post type) automatically based on a comparison between the current time and a number of hours previous to now, for example 24 hours. The custom post ...
0
votes
0answers
117 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( ...
0
votes
1answer
106 views

Query to get all the posts of more than 2 meta_value having same meta_key?

Meta_value will have checkbox infront of them so when both the check box is selected posts related to both the meta_value will be displayed.
0
votes
1answer
27 views

widget exclude post by custom field

I have a widget that gets posts from different post_type's. I want to exclude some posts that have a custom field value e.g. I save a form where a checkbox adds a value of 0 or 1 depending if ticked. ...
0
votes
1answer
33 views

Echo only gives me the first part of string

So I was pulling some meta_value and trying to use it in a mass email and tested it first by echoing what I obtain in the array. In var_dump I see the array and that it gets my correct data, but when ...
1
vote
1answer
248 views

How to create a Custom Meta Box with Name/Value Admin User Input Fields?

I have researched many tutorials on how to create/add Custom Meta Boxes using the add_meta_box() Wordpress function. I can not find any example where the finished Meta Box has the option for an Admin ...
0
votes
2answers
81 views

Grouping posts by a custom meta value

I'm trying to output a list of dates that are held in a meta key called event_dates without duplicates. I've also tried a wp_query with a meta_compare but I'm not able to make that work either. Any ...
4
votes
1answer
118 views

Dealing with Many Meta Values, 30+

I have a "Listing" post type with 30+ meta keys which I feel like can cause a strain on the database when there's 100+ posts. Usually what I do is save each meta value 1 by 1 like so: ...
0
votes
2answers
894 views

WordPress Screwing Up 'orderby' => 'meta_value_num' in 'pre_get_posts'

I have a bunch of _ai_price_int meta values set up as just numbers. This is how the table looks: meta_id, post_id, meta_key, meta_value 1309, 1111, _ai_price_int, 6550 1310, 1115, ...
1
vote
2answers
113 views

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 ...
0
votes
1answer
45 views

How can I use 'orderby' => 'meta_value_num' to order by the numerical value even if the value starts with a word?

I'm using 'orderby' => 'meta_value_num' to order some boats I have as a custom post type, the meta values ordered by, are boat models, which are normally just numbers but if you look at this page: ...
0
votes
0answers
365 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 meta ...
0
votes
1answer
500 views

Does meta_value (array) work with 'orderby'?

My goal here is to query posts by a meta_key, with the values falling in between 1-100. When pulled, it is suppose to be ordered by ascending starting from 1 to 100. $post = array( ...
0
votes
1answer
478 views

Sort column on meta key and meta value

In the WordPress backend I'd like to sort a custom post type column on a meta key and meta value. The meta key is called 'status'. I've got three different meta value's for the 'status' key. How can ...
5
votes
4answers
3k 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 ...
0
votes
0answers
107 views

Custom Field: Display only if a specific key is selected outside the loop

I might be doing this all wrong. I have a custom field called "enable_adsense" and the value can be either "yes" or "no" What I'm trying to do is display something if the value is "yes" and something ...
0
votes
1answer
46 views

How to output meta_key in wp_postmeta?

I have a meta_key in wp_postmeta called _su_description. How do I output its value?
1
vote
1answer
456 views

Query multiple meta values

I'm working on a 'checkbox filter' to query posts by checked values. See this link (EDIT: As you can see there are just 2 posts in this link, as soon as the user checks for 'MINI' it gets a good ...
0
votes
2answers
110 views

Sorting past events by month

I have a site that lists upcoming events and past events. In my category-past-event.php template, this is how I've gotten past events appear in descending order (from most recent to oldest): ...
0
votes
2answers
129 views

meta_value and meta_key filtering returning no posts [closed]

this might sound like a very stupid question, and I am almost ashamed to put it here... however, after using the code straight from wp codex, and trying a couple of other variations from googling ...
0
votes
1answer
139 views

updating one custom meta field only

i am trying to update only one custom field that is store in serialized form. By updating that field my other custom meta fields becomes blank/empty. how can i update only a specific meta value ...
1
vote
1answer
406 views

AJAX pagination offset returns same post on adjacent pages

I have a simple AJAX pagination that seemed to work just fine, calling one Wordpress page (not ideal, I know) with a pagenum and a sort order arguments and it returned 4 custom posts per call. The ...
2
votes
1answer
3k views

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' => '>=', ...
0
votes
1answer
522 views

How to get a value from comment meta

I've add the field country in the comment form. Working nice and I can see the value in the table commentmeta. Now I try to display this value in my comment list. In my single.php I call the list ...
0
votes
0answers
365 views

Check if meta_key exists in wp_list_pages

I have added a custom field (using Advanced Custom Fields plugin) to a page allowing you to show/hide it with a simple checkbox, i want to filter out these pages if a user is not logged in so i am ...