0
votes
0answers
24 views

Show sticky post before other WP_Query

$recent_posts = new WP_Query( array('posts_per_page' => $blog_num_posts, 'paged' => $paged, 'post_type' => 'post', 'post_status' ...
0
votes
0answers
22 views

WP_Query Order by Specific Post ID First

I'm creating a website where I have a need to show a set of posts from a custom loop but I need to display a specific post first. This post will be dynamically specified in the URI by a $_GET ...
0
votes
1answer
16 views

Orderby two meta fields not working

Good day. I have the following code: $args = array( 'post_type' => 'property', 'tax_query' => array( array( 'taxonomy' => ...
0
votes
2answers
53 views

WP_query orderby not working after WP4.0 update [closed]

On my Wordpress-website, I have a custom post type used to display events and a page showing all events in the database. On that page, I'm creating a new WP_Query and displaying the results ...
0
votes
1answer
22 views

Custom query to order by multiple taxonomies

I got this website from a customer to fix some bugs. They are a car dealership. The previous developer created a custom post type (vehicle) and there are two taxonomies: make and model. (they are not ...
1
vote
1answer
48 views

How to set multiple `orderby` in query argument?

I am trying to fetch pages by multiple ordering. menu_order in descending and title in ascending. Following is the argument: $args = array( 'post_type' => 'page', 'posts_per_page' => 20, ...
0
votes
1answer
54 views

Order posts by date and then by custom field

I am trying to do something like this one. Ordering posts by day (not time) AND meta value I want to list blog posts ordered by date (not time) and then within that day, I want to sort them by custom ...
1
vote
1answer
73 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
1answer
35 views

Sorting posts by Multiple custom fields in defined order

I'm currently sorting some posts out by custom fields 'role' and 'surname', using the following: function customorder($orderby) { return 'mt1.meta_value DESC, mt2.meta_value ASC'; } $args = ...
0
votes
0answers
21 views

Order by post_type within loop

Envision the following: <?php $args=(array( 'post_type'=>array( 'premium_content', 'post'), 'posts_per_page' => 3, 'orderby' => 'PREMIUM_CONTENT_FIRST!', 'meta_query' => array( ...
0
votes
1answer
30 views

$args Orderby The number

I have this code $cat_args=array( 'include' => '42,210,21', 'orderby' => '42,210,21', 'order' => 'asc' ); $categories=get_categories($cat_args); foreach($categories as $category) { ...
0
votes
2answers
54 views

How do I order pages and categories by ID or name in the same query?

I would like to query most of my pages and categories on the homepage. So far I am able to get the pages and category (posts), but I cannot order the list the way I want to. I want to be able to get a ...
0
votes
1answer
165 views

WP_Query order result by date AND meta_value

I have searched but not found an answer to my problem. I have posts with a meta key used for ordering. I want to order post by this value. If they have same value I want them to be ordered by date. I ...
0
votes
0answers
73 views

Query category-specific, paginated posts and allow viewer to change sort order

Maybe this has already been asked here, but I can't seem to find a solution, so forgive me if this is a duplicate. I have coded a custom template to display all posts from a category with the ID 36. ...
0
votes
2answers
63 views

How to order posts in wp_query by a meta_value of the corresponding author

Is it possible to order posts retrieved via WP_Query according to a meta value of the corresponding post author? Use case: I have premium subscribers and basic subscribers. I want the posts of the ...
0
votes
1answer
67 views

Previous/Next Link by Meta Value in CPT

I'm using the following code to paginate between custom post types and it doesn't seem to be using the meta_key or meta_value_num and I can't figure out why. The CPT is set-up to have hierarchal => ...
0
votes
0answers
31 views

WP_Query 'orderby' => 'title-of-parent title'

How can I order a query by parent page attribute first and then by child page attribute? By title or by menu_order is acceptable. For example, if my query matches child pages, and my search results ...
0
votes
0answers
39 views

query_posts with sorting on a custom datestamp

I have a custom meta field that I want to use to sort with query_posts but its not ordering my posts properly since it is a datestamp (i.e. 04/21/2014) and its treating it like a normal text string. ...
4
votes
2answers
360 views

Order by optional meta key?

I'm building the sorting functionality for a custom post type, and I have a custom meta value for "Featured" posts. This value is set when you tick the checkbox, otherwise it is not set. Using the ...
0
votes
1answer
81 views

Get post closest to today

as the title indicates I am trying to make a query for the post closest to today's date. I know this is a duplicate post but the ones I have found on the topic has not been able to solve my problem. ...
2
votes
1answer
90 views

Custom Post order for homepage

I would like to display a dropdown on the homepage which contains [most popular, most recent, trending] and when a user selects on of them the posts are page reloads and the posts are sorted in that ...
0
votes
2answers
45 views

Order by multiple meta keys on wordpress

After multiple research I didn't find the correct answer to my question. I just need to order my custom post type by date and then by time (format: 18:00). Here's what I tried: ...
0
votes
1answer
289 views

Merge 2 args in one WP_Query and order it by date

I'm trying to merge 2 WP_Query in a new WP_Query and then order all posts in this new merged query by date descending. I can merge 2 WP_Query and work fine, but I can't order the new query $args1 ...
0
votes
1answer
83 views

Randomly select one of last 3 posts

ok so i have this: $args=array( 'orderby' => 'rand', 'order' => 'DESC', 'posts_per_page' => 1, 'offset' => $offset, ); $q = new ...
0
votes
2answers
65 views

Order posts with custom taxonomy array

I am trying to make my loop go through the posts that are associated with these terms. Currently nothing is being output. <?php $args = array( 'post_type' => 'staff', ...
0
votes
0answers
98 views

orderby in WP_query doesn't works

I thought that this already works but now I tested it and it seems that it no longer works. I have this code: wp_reset_query(); $args=array( 'posts_per_page' => 3, 'meta_key' => ...
0
votes
0answers
91 views

Orderby comment_count ignored if multiple orderby values

I'm trying to order my archive page by comment_count then title. add_action( 'pre_get_posts', 'my_change_sort_order'); function my_change_sort_order($query) { if (is_archive()) { ...
0
votes
1answer
156 views

Posts2Posts, wp_query and orderby issue

I've been working on this issue for several hours now and I'm stumped. The following query refuses to accept any orderby directive. NOTE: This is running on a single-cpt.php page within the normal WP ...
0
votes
1answer
5k views

Order by DESC, ASC in custom WP_Query

I need to do multi-level ordering in a query. The issue is with ordering one value DESC and the other ASC as in SQL. The following SQL seems to give me what I want when I run it in terminal: SELECT ...
0
votes
1answer
570 views

wp_query orderby random do not repeat infinite scroll - one loop

I have found a lot of documentation on solving this issue with multiple loops, I'm finding it hard to see a solution for one custom loop. Problem: I'm using infinite scroll to load in the next page ...
1
vote
2answers
876 views

WP_Query orderby post__in remains ineffective in the Loop [closed]

I’m trying to query a custom array of posts for the homepage, trying to maintain the order given in the array. To a certain degree this works fine, WordPress finds the posts, but in the Loop the order ...
2
votes
2answers
869 views

Sorting: custom query with orderby meta_value_num THEN by title

i try to run a custom post type query to match following criteria: sort movies first by year in descending order, after that ("inside" the year order) by title alphabetically. desired output: ...
0
votes
1answer
573 views

WP_Query with several meta_query-statements and order by meta_value

This is my query: $the_query = new WP_Query( array ( 'post_type' => 'pass', 'posts_per_page' => '-1', 'post_status' => 'publish', ...
1
vote
1answer
85 views

Reverse chronology of post listing

I"m working on modifying a theme that is based on 2010. I want to make the posts on this blog display earliest to oldest, but I don't see how to do this in the theme: I understand I need to add . ...
0
votes
1answer
80 views

404 on Pages for Custom Post Type & Query_Posts

It took me quite a while to find a good solution for ordering a custom post type by two custom meta keys. When I finally got it working, I found out the pagination no longer works. I've tried dozens ...
0
votes
1answer
287 views

Custom loop of a single category, cannot order by date. What am I missing?

I'm going nuts. All I have is a simple loop on the home page of the site (which is a static page), and it should show the most recent (1) post of a certain category. The trouble is no matter what i ...
2
votes
2answers
140 views

How to query different post types in specific order?

I have 3 posts types, articles, news and tips. On the home page I want to query 20 posts in this order: article, article, news, news, tip, ...// same order again until 20 If I use a custom query ...
0
votes
1answer
61 views

Specify strict 'order by' in WordPress query

I have a custom post type called Employees where an employee's name is the post_title of each post. I am trying to figure out how I would sort the post_title column by last name. So for instance, if ...
1
vote
2answers
852 views

Wp_query: sort by PHP variable

Here is my problem: For my articles, I use a custom post type "exhibitions" and posts for all other news. I am displaying them in one query ['post_type' = array('exhibitions','posts')]. The orderby ...
0
votes
1answer
721 views

WP_Query orderby not working with meta_value_num and menu_order

I have made a custom post type (sidebar_element) which are shown on sidebar. On each sidebar element admin can choose where in sidebar should that element be shown, ie. 'top', 'middle' or 'bottom', ...
0
votes
1answer
360 views

reorder a WP_Query, using a dropdown

I have the following loop used to display posts by category & I would like to to re-order them based on a dropdown selector if (!isset($qry)) $qry = new ...
1
vote
3answers
440 views

WP_Query orderby breaks when using AJAX?

I'm running in to a bit of a problem. I have a function called get_press(), it retrieves newest press items. It is inside of a plugin: class EWPress { function __construct() { ...
0
votes
1answer
177 views

How can I sort posts by the date and a custom meta field?

I have custom meta field that I use for the post rating. So I want to display posts by the date and the rating, but only for the posts that have specific rating. For example, I want to display posts ...
0
votes
1answer
732 views

Displaying Portfolio Filter by Category Order (alphabetically)

I have created a custom post type to display churches in Europe. I used a tutorial to make it filterable and everything on my site works as normal. How would I organize the posts by country, instead ...
0
votes
1answer
1k views

WP_Query ordered by custom field that is a date string?

Each of my posts have a single custom field that is a string of a date (not the date of the post). Instead of my theme's current query, which orders by published date, I want to order by this custom ...
0
votes
1answer
466 views

WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)

I'm trying to write a new "related posts" widget (for the single post view) for my custom post type, filtering by custom taxonomy terms that the related posts should have in common with the current ...
0
votes
1answer
399 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
1answer
679 views

How to Order a list of taxonomies? orderby?

I am using this code to fetch a list of child taxonomies. I want the order displayed to be alphabetical, but it is not! Any help in figuring out how to do it? I guess ordering it before returning it ...
1
vote
2answers
162 views

How do I sort posts with multiple pages

I am using a drop-down to sort posts by title, meta_value, etc. However, the sorting feature only works on the first page. The second page displays the default order rather than continuing the order ...
3
votes
1answer
473 views

Order posts by ID in the given order

In the back-office of my theme, the users can choose which posts to display in the front page, and they can also choose in which order the selected posts should appear. I have tried like this: ...