1
vote
0answers
32 views

WP_Query orderby and tax_query

My goal is to have custom posts type's posts (CPT for simplicity) from a custom taxonomy (CT for simplicity) let say CT Hometown with slug Nebraska to be listed grouped by another CT, let say ...
0
votes
0answers
13 views

Meta query not working with pre_get_posts

This works $q->set('meta_key', 'available-date_%_from'); $q->set('meta_value', '20140701'); This doesn't $q->set( 'meta_query', array( array( 'key' => 'available-date_%_from', ...
1
vote
1answer
30 views

How to get a query variable?

I have added a query variable with the following function: function add_my_query_var() { global $wp; $wp->add_query_var('myvar1'); } add_filter('init', 'add_my_query_var'); Now on a ...
0
votes
0answers
16 views

add_query_vars does not work

I have added this code in the TwentyFourteen theme's functions.php file. function add_query_vars($aVars) { $aVars[] = "msds_pif_cat"; return $aVars; } add_filter('query_vars', ...
0
votes
0answers
16 views

Build query from the url given

I have an ajax request coming with parameter called "next_page_url" => "URL_FOR_THE_NEXT_SET_OF_POSTS" Now I need to build a WP_Query arguments using that url to respond to that AJAX request with ...
4
votes
1answer
89 views

How to uniquely identify queries?

Today I was thinking about how to differentiate queries, mainly to create an unique identifier. In the process I played around a bit, see below code. The main idea is to do it depending on the ...
0
votes
0answers
25 views

A Depth Like Parameter For “get_posts”

Wordpress has stumped me for the first time in a very long time. I am trying to limit the depth of a get_posts call in my template. I want to get children but limit it to a depth of only 3 as I am ...
0
votes
1answer
35 views

Need help setting up a search form for wordpress [duplicate]

I want to set up a search function as a widget in wordpress. This is the situation that I have. 1- I have 3 custom post types 1.a: Each post type has custom fields and taxonomies. I have regular ...
0
votes
1answer
44 views

How to get list of posts from permalinks?

I am using an API which tracks metrics on parts of my site. The only useful bit it saves though is the URL (permalink). What is the most efficient way to query up all the posts that match those ...
0
votes
0answers
14 views

How to cancel a custom post type query based on existing cache file

Is there a proper way to greatly restrict the query (or remove it altogether) for a custom post type type-single.php file? Simply stated, for reasons of speed speed speed I've cached all relevant ...
0
votes
2answers
31 views

Modify Search Query if original Query gave no results

I'm looking for a way to modify the search query if the performed query returned no results. Let's say I'm looking for "Opening times", so I go to this URL: http://mysite.com?s=Opening+times Now, ...
0
votes
1answer
31 views

Pagination not working with WP_Query (creates links but no page)

The following loop gets all posts within a relevant category. It does generate a pagination URL, but it does not take me there (it just redirects back to the homepage). Would anyone know why? $paged ...
0
votes
1answer
28 views

Querying Posts by Taxonomy From Alternate Network Site

I have 5 Network sites in my WordPress multisite setup. One of which is the "primary website", which the rest of the other network sites will be retrieving data from. I am currently using ...
0
votes
1answer
103 views

Filter post query to only show direct children of category

Google seems all purple on this subject, if you know what I mean. I've searched for this topic forever to find a solution. I want to build a finder/explorer feel to my categories, so when browsing to ...
1
vote
0answers
126 views

Query by 2 values of a repeater ACF field

Let's say I have a custom post type called Film, with a repeater field called Showings, with fields start_datetime and discount. I need to make a query for those Films that have at least one showing ...
1
vote
2answers
50 views

Different Ways to Query Custom Post Types?

I'm using this code to use custom post types like regular post: add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) { if ( is_home() && ...
1
vote
0answers
169 views

How to get latest posts from each category in regular order

let's say I have a main query and it displays posts from Movies and Music categories. I want the query to show always 5 latest posts from Movies and 5 latest posts from Music category. When I create a ...
0
votes
0answers
47 views

wordpress page filter problems

Hello I been working on post type filter so I can filter my content for taxonomies type but for what ever reason I can never get it to filter when I click filter public function product_filters( ...
0
votes
1answer
48 views

How to SQL query posts IDs by categories AND authors?

I am making a custom WP_Query and I need to come up with a SQL query that gets the posts IDs from X categories and Y authors. Then merge those IDs and put them in an array. I only need to figure out ...
0
votes
2answers
27 views

Include both default and Custom Post Type in query modified inside pre_get_posts

I want to include custom post type in the author arhive page. I tried the method discussed in this post: Including post_type = 'wiki' in author archives add_action( 'pre_get_posts', ...
2
votes
1answer
68 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
1answer
42 views

Minimize database queries to user tables?

I'm trying to come up with a strategic way to collect large amounts of usermeta data (and output to the screen) while keeping database queries low. Some pages, like the home page, single pages, and ...
0
votes
0answers
40 views

Query custom post type by date field only working when two posts match the query

Hi I am trying to query a custom post by an advanced custom field that is a date field and this is how it is registered in a plugin that I have created to take care of all non-visual aspects of the ...
0
votes
1answer
329 views

meta_query on a date range using an array of values

How can I do a query to return the post if the custom field array contains a date that is within the specified range? The query below is basically what I am after but it does not work... // the ...
0
votes
1answer
15 views

meta_query dates from an array

I have the below query which isn't returning anything. The query is meant to look for the date (2014-03-01) that is in the array, which it is. Any ideas? Or would I need to use a custom SQL query? ...
0
votes
0answers
51 views

Query post names based on tags of current post

I have a custom post type called 'employer'. In some of my normal posts, I use the slug of an employer as a tag to link the two together. For example POST A mentions "Adidas" and therefore I add ...
1
vote
1answer
238 views

How to reduce the number of queries?

I have meta key "Due" for posts....if a post has expired (past the current date or not equal to it) then it will not be displayed in the count. This is my code, which works perfectly. My only problem ...
0
votes
2answers
33 views

Unable to paginate a custom page query

I have this code on a page called Categories. <?php /* Template Name: Categories */ get_header(); ?> <section id="primary" class="content-area"> <main id="main" ...
1
vote
1answer
106 views

Should 'setup_postdata()' be reset with 'wp_reset_postdata()'?

Starting with an example makes more sense, so here's an example function: function seo_meta_tags() { global $post; if( is_singular() ) { setup_postdata( $post ); ...
0
votes
1answer
89 views

Divide WP_Query posts by date & post type

I have a WP_Query that divides 2 Posts types by date but the functionality is not there. Currently it outputs the dates and posts on the same level like.. -Date -Post -Post -Date -Post -Post What I ...
1
vote
1answer
58 views

Only display a certain number of posts, dependent on how many posts there are available in a query

I am trying to write some code for a slider of posts, at the moment my code involves two WP_Querys, one inside the other, but I can't help feeling there may be a more efficient way of doing what I'm ...
0
votes
1answer
65 views

Query child posts on parents single.php?

Is it possible to query the child posts of the single post your on? i.e you have a custom post type called apples. The parent page is... single-apple.php On that page query and display all its own ...
0
votes
0answers
232 views

Query Posts From Multiple Post Types

Is there an easier or more efficient way of querying posts from multiple post types by the date of which they were published? I read this question here: Using Query Posts With Multiple Post Types And ...
0
votes
2answers
131 views

Get a list of posts by specific category

I'm trying to build a search query in PHP in WordPress and I need to get all posts by a specific author in a specific category including drafts. For example, is it possible to do something like, ...
0
votes
3answers
201 views

Is_single() conditional tag returns null in query

Trying to figure out why this won't work for me. I'm simply trying to run a loop of all posts and pages, and tag them as post and page in a array. But the is_single() conditional is not working, all ...
0
votes
2answers
247 views

Should $found_posts be returned as string in 'found_posts' filter hook?

In general a function that hooks into the found_posts filter looks like this: add_filter( 'found_posts', 'adjust_offset_pagination', 10, 2 ); function adjust_offset_pagination( $found_posts, $query ) ...
1
vote
2answers
47 views

Exclude the first 'n' number of posts of a tag from home page?

Use case (example): Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query. I don't want the ...
0
votes
1answer
291 views

Using in 'category_name' in '$query->set();'?

Here's the function I have in my theme's functions.php: function better_editions( $query ) { // Categories act as 'Editions' on my site $get_edition = get_query_var( 'category_name' ); ...
0
votes
2answers
327 views

Sort posts by category name and title

Trying to figure out how I can output my posts based on category title (a–z) and secondly, the title of the posts within the category: A CATEGORY – A post beginning with a – Because I want to be ...
0
votes
1answer
114 views

Retrieve posts in custom post type and specific taxonomies

I'm struggling with what seems like should be so simple looking at the codex. I have a custom post type, let's call it 'portfolio'. A custom taxonomy for that, let's call it 'clients'. I can use ...
0
votes
1answer
61 views

How to query post ids liked by the Author

I'm using wti_like plugin and this is how i get the number(count) of post liked by the author // Get the author object $author = get_user_by( 'slug', get_query_var( 'author_name' ) ); // Get the ...
0
votes
1answer
277 views

Show a 404 error page if Public query variable's value doesn't exist?

Public query vars are those available and usable via a direct URL query. On my site, I've created some custom URLs with their own query variables like so: ...
0
votes
3answers
38 views

Include one page/post into query which is already returning posts

I have my news query which is on my index file. I want to include a post into this query which is infact a page. Is there anyway to do this? <?php query_posts(array( 'posts_per_page' => ...
0
votes
1answer
51 views

I am officially missing something about transient posts

I have no issue creating transients. What I have an issue with is pagination - and I have made posts on it before and every one sates that the query must look like, for example: $queried_post ...
0
votes
0answers
16 views

WP_Query by date not working? [duplicate]

I'm using a function that returns posts using shortcode. My 'featured posts' are to be any category with the highest comments and only for the week. I have looked over the documents and even did a ...
0
votes
0answers
103 views

Join two wp_query

So, i have custom posts with this settings: Example 1: have meta_key "price" Example 2: have meta_key "no_price" So, i want to list this posts ordered by "price". I just want to join these two wp ...
0
votes
1answer
189 views

Insert images into wordpress post with a query

I have a Wordpress installation with 2.000 posts. Also in a separate table of my database I have a set of image paths and the filenames of the images, each image is assigned to each post of my ...
1
vote
2answers
48 views

Querying Term Posts in Loop

I'm trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine: <?php $cats = get_categories(array('taxonomy' => 'custtax', 'orderby' ...
0
votes
1answer
71 views

Meta Query for specific months

I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm ...
1
vote
1answer
72 views

if/else on custom query gives 200 OK when condition not met?

What? I am modifying my theme to show comments of a post on a separate page. How? Mostly based on this answer but with improved checks and code. So this is what my page-comments.php (kinda) looks ...