"wp-query" ambiguously refers to one of two things. 1) WP_Query is a class native to Wordpress which allows users to query the posts database using a number of criteria. 2) $wp_query is the default object that holds the main query object on each WordPress page.

learn more… | top users | synonyms

1
vote
5answers
732 views

WP_Query returns no results

I'm using wp_query to create a custom query that retrieves search results but it is returning 0 results. Here is the code: $query = 's=the&posts_per_page=5&paged=1'; $custom_query = new ...
0
votes
3answers
96 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
1answer
285 views

How to create/modfiy WP_Query to search in post title OR custom field?

I need to modify or create a WP_Query that will search for a search term in both the post title OR a custom field (called 'my_field'). I have been reading and trying for hours, but I am right back to ...
0
votes
1answer
599 views

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

Randomize Posts. Skip the first post in ascending order

I'd like to randomize a set of posts (custom post type), but ignore the first post all together. Here's the code I thought would work: $featured_content_query = new WP_Query( array( 'post_type' ...
0
votes
0answers
22 views

Custom Search Not Consistent with Results

I've set up a custom search to use the s GET variable on a URL. I want it to fetch certain results but I've come across an odd problem. First, here's my code: $search_term = $_GET['s']; ...
0
votes
0answers
11 views

How to modify WP_Query outside the loop?

I am running a WP_Query which shows some posts and the posts are added into an array of Object. How can I modify the array of Object outside the loop. My Code is: $original_blog_id = ...
1
vote
2answers
54 views

Why won't my taxonomy query show up?

I'm attempting to display posts from a 'Uncategorized' category under a custom taxonomy called 'Reviews' but without much luck. I'm using get_template_part('loop','review') to call loop-review.php ...
0
votes
2answers
546 views

Recent Posts slider, using WP_Query(), loads duplicate sliders

I have written a small piece of code for Wordpress that will show the most recent top 4 posts in a slider (the Filament Group Responsive Carousel). It works, displaying the posts and sliding them etc, ...
0
votes
2answers
338 views

How to sort queried pages by an array of page ids?

I'm creating a one page wordpress website, and I need my 'home', 'about', 'portfolio', 'services' and 'contact' pages to all be on my front page. I created the following page template for my front ...
0
votes
2answers
370 views

Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”

I am trying to display 3 post_thumbnails from a custom post type "portfolio" on my homepage template. So one from post 'A' , one from post 'B' and one from post 'C' The image from post A will be set ...
0
votes
2answers
317 views

Unable to combine “search value” and “tax_query” using WP_Query

This is my function in my template's functions.php. The problem is that this is working: function ajax_search_action_do(){ global $wp_query; $search = $_POST['search_value']; $country ...
0
votes
1answer
19 views

How to create Page templates for showing Blog posts in different layouts?

I'm creating a Wordpress Theme, and I want to create few Page Templates for creating Blog pages with different layouts. So for example, I want to have blog-4-column.php, blog-3column.php and ...
0
votes
0answers
10 views

WooCommerce order by “rating” [on hold]

I have this shortcode, to show the featured products, but I want to order them by the rating, anyone know how can I do this? Shortcode: function featured_products_shortcode($atts, $content='') { ...
0
votes
0answers
30 views

there's something like re-route concept in wp?

I'm using Woocommerce with a premium theme, have some product category. I would like to hide one category if the user is not logged in or not in a given role, by hide I mean don't show the products ...
0
votes
1answer
16 views

Remove duplicated posts in the loop if post has more then one categorie

I have some posts with more then one categorie. In the post loop i get the post based on the selected categorie by the user. If the user select 2 categories where one post is assigned to, the loop ...
0
votes
1answer
549 views

Loop through Custom Post Type, and then show children within each iteration

I am currently using WP_Query to loop through a custom post type, and only showing the parent posts like so: <?php $loop = new WP_Query( array( 'post_type' => 'programs', ...
0
votes
0answers
16 views

WP_Query - How to orderby parent publish date?

I am using WP_Query to display 'post_type' => 'attachment' on a different page than the posts they are uploaded to: $media_args = array( 'post_type' => 'attachment', 'post_status' => ...
0
votes
0answers
15 views

Only show top level posts of specific category

I've been trying to create a loop that will only show the top level posts no children/sub category posts. Basically what my categories look like are -- -All --one --- A --- B -- ...
0
votes
1answer
516 views

Pagination doesn't work

I created myfile.php with the following content: global $paged; if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); } else if ( get_query_var( 'page' ) ) { $paged = ...
-2
votes
0answers
15 views

Fire function when query_var is set?

I am using add_query_arg('foo', 'bar'); - and I would like to have a function fire when one of these specific query variables is set. Is this possible?
0
votes
2answers
2k views

How to get only ONE category of “Portfolio” posts to display on main page rather than ALL categories?

I have a section on my main page that displays a new “Portfolio” post each time I write one no matter what category I assign them to. What I want to do is make the main page only display one specific ...
0
votes
0answers
18 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 ...
0
votes
1answer
310 views

Fatal error: Allowed memory size of 37748736 bytes exhausted …, on larger offset query parameter

I hope this is not a duplicate question. I have a custom .csv generator functions that basically export data from posts and its post metas. The function works fine on this WP_query parameter: ...
0
votes
0answers
12 views

Filter terms bases on multiple taxonomies - operator not in? [duplicate]

Building a function for filtered taxonomies. How to use 'operator' => 'NOT IN' or 'operator' => 'IN' inside the query to only show tax_query terms that are connected to all taxonomies instead of ...
0
votes
1answer
30 views

relation OR instead of AND - Filtered term ID's in loop

Question not related anymore.. First I tought about the relation OR/ AND for results, but I believe I should work with 'operator' => 'NOT IN'. I would like to query the results that meet multiple ...
0
votes
2answers
2k views

Get posts by meta data OR title

I have a working query that calls all my posts that have a certain meta value for one of two meta keys: $term = $_GET['term']; $args = array( 'post_type' => 'some_cpt_name', 'meta_query' ...
1
vote
2answers
238 views

Pagination problem after WP_Query with tag filtering

I have a problem with a custom WP_Query. I want a page with all posts with a specific tag. This is the code I'm using: <?php //save old query $temp = $wp_query; //clear $wp_query; $wp_query= ...
0
votes
2answers
27 views

Archive page - problem with pagination

I have a problem to display pagination using WP_Query. I've created a custom page, code below: <?php /* Template name: Models */ ?> <?php get_header(); ?> <?php the_post();?> ...
0
votes
0answers
130 views

wp_query->max_num_pages always returns 0 on custom post type

Hi there I am developing a theme where I have to load some posts with ajax, in my index page everything works properly, the problem is when I need to use it on custom post type, I pass the values for ...
0
votes
1answer
25 views

Query seems to be duplicated

I'm just hit a development brick wall and can't seem to find a solution to this problem. I've running two WP_Query's the aim is one displays premium stockists and the other one displays the none ...
2
votes
2answers
198 views

Extending WP_Query — Optimise SQL query

I'm storing posts, a user follows in a custom table that has the columns id, post_id and user_id. To fetch posts that a user follows I have extended the WP_Query as follows: class ...
0
votes
2answers
716 views

Display featured posts for a custom post type by taxonomy

Ok, the quick explanation: I'm using a custom post type, 'lakes'. And, using custom taxonomies to organize them. They are: state, watertype and county. I've created a 'page' for each state that ...
6
votes
3answers
84 views

Can I force WP_Query to return no results?

I'm working on a website with a search feature that allows users to search through a lot of post meta. There is a specific search pattern that I would like to forcibly return no results for. The ...
1
vote
1answer
27 views

get_the_title($postID) OR get_the_title()?

I would like to know which could be more performant between these two approaches of getting data of a post To use a loop after a WP_Query($aConditions) and use functions like get_the_title() ... and ...
1
vote
1answer
31 views

Get current post id in functions.php

I have a wp_localize_script() function in my functions.php where I need to push the current post ID of the current post to a jQuery file. So I was wondering how you can get the current post ID of a ...
2
votes
1answer
290 views

Gravity Forms field entries into wp_query loop

I have a simple function that filters the page content when form (ID 18) is submitted. It simply displays the entry of field (ID 13)... add_action("gform_after_submission_18", "set_post_content", 10, ...
9
votes
2answers
7k views

Meta_query compare operator explanation

I noticed that there are bunch of operator can be use for compare in meta_query. However, I am not quite sure what operator I should use, it is somehow confusing like = and LIKE operator. I would ...
0
votes
0answers
29 views

Add custom fields meta_query to wordpress search function

I'm trying to extend the wordpress search function to include custom fields using the pre_get_posts filter: function test_custom_search_query( $query ) { $adv_custom_fields = array( 'field_1', ...
4
votes
1answer
819 views

How to paginate wordpress [gallery] shortcode?

I am using wordpress gallery shortcode [gallery] I was wondering if there is anyway to paginate them without using a plugin.
1
vote
2answers
34 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() && ...
3
votes
1answer
356 views

WP_Query ignores post_type in category view

I have following query to select posts by my custom post-type. This works fine while being on the frontpage (the snippet is included in the sidebar). As soon it gets executed on a category page the ...
1
vote
1answer
19 views

Advanced Query Logic With Multiple Taxonomies

I have a page on my site that acts as a search tool/search results page for users to find rental spaces. On the left side is a column of checkboxes that let the user filter the results by three ...
1
vote
0answers
48 views

WP_Query tax_query problem

When I call WP_Query with tax query or category__in, I get posts only from first category in array of requested categories. $query = new WP_Query( array( "tax_query" => array( ...
0
votes
1answer
295 views

Multiple keyword search

I have a custom search where I want to enter a keyword or phrase into the search box, and then by pressing enter it adds it to a 'search storage' (already coded, see below). Asume I have 3 posts, one ...
1
vote
4answers
2k views

Export wordpress table to excel

I have created PHP scripts before to export a database table to .xls format like this: $select = "SELECT * FROM tracking"; $export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) ...
1
vote
1answer
46 views

Unable to get paginate_links working with a custom query [duplicate]

I have built a news section in my Wordpress site with the advanced custom fields and custom post type ui plugins. On the custom news overview page (not the standard wordpress posts) I wanted to limit ...
1
vote
1answer
46 views

Show most popular post of last 12 months

I use the Ribbon theme that has a nice tabbed widget showing the most popular and most recent posts. I would like to limit the most popular posts to the last 12 months. I would rather not use a plugin ...
1
vote
1answer
17 views

How to count post meta key values for all posts in database

In my post meta data I have the following 'key' for every post: "image_details" a typical value of which is an array such as: ...
1
vote
1answer
335 views

Query by meta_key and order by meta_value_num return orderby date

I'm trying to use the orderby and custom WP_Query features of wordpress. It works nicely to select item by their meta and to order by date. Unfortunately, it seems that I could not get the post ...