"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

7
votes
4answers
6k views

Broken? WP_Query and “attachment” as a post type

I have a gallery attached to a page. On that page, I'm running the following query: $events_gallery = new WP_Query( // Start a new query for our videos array( 'post_parent' => $post->ID, // ...
0
votes
0answers
18 views

's' term in WP_Query extended class causes huge memory leak (268MB)

I've used WP-Geo-Posts as a starting point for building a plugin which extends WooCommerce to support classifieds-like functionality. Using ACF I've associated products with a location (latitude and ...
0
votes
1answer
15 views

Overriding $wp_query on a template

What would be the disadvantages/problems of overriding a global variable, in this case the $wp_query? Example in template archive-books.php: get_header(); global $wp_query; $wp_query = new ...
0
votes
0answers
11 views

Call grand-children of page outside a loop?

I am knocking my head to a wall since couple of days, Here is the situation ( I attach a graphic to explain more clearly what I want): I have one main page-template. Who is the parent of three ...
0
votes
0answers
13 views

Comment form on page redirects back to frontpage

I have a page template with a single WP_Query what displays only one posts (Depends from the value of the $_GET. Example: domain.com/custom/?id=2). I would like to add a comments form I used ...
0
votes
1answer
7 views

Displaying the category name of a custom post type

So I have a custom query, in which I'm displaying some results posts of a custom post type called "staff". This custom post type is linked to a custom taxonomy called "department". I am able to ...
0
votes
2answers
18 views

Limiting number of related posts

I'm trying to add a related posts section to the bottom of my single post views. It needs to grab the categories of the current post and show just 2 posts that match any of those categories. I'm ...
0
votes
2answers
14 views

Compare meta key separation

I have a meta key called $availability that can have one of four options but also multiple values separated by pipe: |. For example the value could be: severaltimes_week|oncetwice_month|occasionally. ...
0
votes
1answer
16 views

wp_query - show pages that have parent defined

Can I achieve this with wp_query? I only want to get pages that have parent selected. I'm using JSON API plugin and need to make a http request - would this be possible with url wp query also? For ...
1
vote
2answers
1k 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 = ...
1
vote
1answer
466 views

Pre_get_posts Gives 404 on Custom Post Type

I'm trying to filter the query on a sub page called "Ask Question" to list all of the recent questions submitted by users, but I get a 404 when going to the page. Flushing the permalink structure did ...
0
votes
0answers
13 views

creating one page theme but templates are not being applied to page content on the “one”page.

I am creating a one page theme. I have a loop that puts the content from each page on a single page but it does not apply the temple for each individual page. Here is the loop I am using. <?php ...
1
vote
0answers
18 views

Slow WP_Query with 'OR' on meta_query

Essentially, I'm trying to query using a filter for the args being fed into WP_Query() like so: public function filter_wp_query( $args, $template_slug ) { $args['post_type'] = ...
1
vote
2answers
335 views

How to display future posts - modified query still yields 404

I have a very strange problem and I am stuck. I want the single page to display posts with the post_status of publish and future. So I added this code to my functions.php in my theme: function ...
0
votes
2answers
42 views

Limit amount of pages shown in pagination within wp_query

I've got a query that looks like this: $args = array ( 'post_type' => $postType, 'paged' => $paged, 'pagination' => true, ...
0
votes
1answer
44 views

new WP_Query messes up pagination

I've been looking around for a solution to displaying a separate amount of posts specifically for the archive pages, and thought I had came up with some working code, however I see it messes up ...
0
votes
1answer
19 views

post_results filter confused by pagination in sidebar and main section

I have a post_results filter that I want to use to manipulate the results returned from a the query. Let's say that it's supposed to put stars around the first post on the first page, second post on ...
5
votes
3answers
820 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
2answers
440 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
1answer
61 views

Query using string from custom field as array value

Firstly, what I am trying to do is display posts from Category x on posts from Category y where text from a custom field on post from Cat y matches text from one of 2 custom fields on cat x. I am ...
0
votes
0answers
8 views

multiscroll confusion in wordpress

I'm using multiscroll jquery plugin for multiscroll. here is the code from documentation of plugin.. <div id="multiscroll"> <div class="ms-left"> <div ...
1
vote
1answer
613 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 ...
0
votes
1answer
24 views

Plugin does not create a custom table upon activation

I have a problem as the title says. My plugin does not create a custom table when it's activated. My code is: function bsp_create_update_table() { global $wpdb; //geting the acces to a wp tables ...
0
votes
3answers
315 views

Remove category from query (show all posts in archive.php) pre_get_posts()

I am using pre_get_posts() to allow all posts to be displayed on any category archive. This is because I will provide a javascript sorting and filtering method using isotope.js. Any category page will ...
0
votes
1answer
36 views

WP_Query shows all posts on single post pages

Looking for assistance with WP_Query. I'm learning to create WordPress themes and I am practicing by creating a real estate theme. What I am trying to do is set up a properties page (custom post type) ...
0
votes
1answer
1k views

posts_per_page is not working

I have a query to display custom post type categories' posts, but I want to limit the posts_per_page to 8, so I am using the code below. Please tell me, if I'm doing something wrong. <?php $args ...
2
votes
2answers
582 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
0answers
16 views

Shortcode in a blog post, footer and related products stop working

I have a problem, I develop a shortcode, and it works fine just that when I put it in a blog post, footer and related products stop working. I show you my code I hope you can help me. <?php ...
0
votes
1answer
808 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
33 views

Get newest value of an array

I would like to show custom posts as an "issues" page. I can hard code the 'terms', e.g. issue-3, but how can I display just the newest one? $the_query = new WP_Query( array( 'post_type' ...
1
vote
0answers
24 views

Add Custom Post Type of specific Custom Taxonomy to regularly blog loop

I want to add a CPT to be shown in the blog. I figured out that I can use the filter hook pre_get_post to get the query object and I can modify it. However just adding another post type to the loop is ...
0
votes
1answer
320 views

Show Posts in Vertical Tabs with Scrollbar

I have created CPT ( Custom Post Type ) called Recipes. I want to display all me recipe in Vertical Tabs. For Example; check the image below i have created. Image Example Click Here On the left ...
1
vote
0answers
28 views

Meta Queries - should nesting work after WP 4.1?

I have a rather huge meta_query here and it hangs at execution: browser just won't load the page, it goes on loading ... As far as I know this should work after WP 4.1 (I have it). Also tried ...
0
votes
1answer
22 views

Display Count of posts

I'm trying to create a counter that will display the page number followed by the page count of a category page, where there is 1 post per page. For example if there are 10 posts in a category: 1/10, ...
0
votes
1answer
18 views

How to filter sql only for a specific post type

I have been trying to join a custom table with a regular wordpress query, but only under a specific condition (a specific post type). I have a single-event.php template that runs the main query, and ...
0
votes
1answer
28 views

Get results from the main wp_query

I would like to alter the main wp_query and then email the results as PDF or HTML email. I have managed to filter wp_query using custom filters and some code similar to this inside my plugins ...
0
votes
1answer
384 views

Group posts by meta_key

I have a Problem with grouping meta_values. The Query looks for posts with the meta key "company". I want a unique listing of the colors like: blue red yellow array_unique was not successful and also ...
0
votes
1answer
565 views

Offset WP_Query by negative 1

I have an event loop and I'm wondering if it's possible to offset the loop by -1, so the prev and next posts of the current post are shown. EDIT - Thanks for your comments, I think I can clarify. ...
2
votes
2answers
103 views

Exclude first 5 posts of specific categories in the main loop

I read this article about how to set an offset for one specific category in the loop. I was wondering about if this was possible for more than just one category. My problem with the code suggested in ...
0
votes
2answers
330 views

Pagination/infinite scroll with WP_Query and multiple loops

I need that the main page of my site have 3 columns: - The first having the 5 most viewed posts; - The second with the next 5 most viewed posts; - The third with the most recent posts. I don't want ...
4
votes
2answers
48 views

Exclude a category if post is only in that category using wp_Query

I have two categories Category1 (ID = 1) Category2 (ID = 2) I want to display posts Which are in Category2 and in (Category1 + Category2). If a post is only in Category1 then it should not ...
0
votes
1answer
9 views

Get all custom posts with a certain taxonomy

So the site i am working on has a Custom Post type of "Case Results" and one of the columns is "Type of Case". On a certain page I need to get all of these "Case Results with a "Type of Case" of ...
0
votes
2answers
25 views

Creating attachments archive in tags and categories

Per this question (How to create an attachments archive with working pagination?), I've been using the following function to have archive pages display attachments as well as pages and posts. It was ...
0
votes
1answer
353 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 ...
0
votes
0answers
17 views

previous_posts_link not working in WordPress pagination

I'm using a custom query in my front page to show some posts from a category. it ll be selected by the admin from backend(using redux framework to do that). Now when I click older entries ...
0
votes
1answer
2k 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
0answers
8 views

wordpress wp_query with redux option is not working [on hold]

I want to have the ability to choose a category from theme option panel & it ll show all the posts from that exact particular category. so I have setup my wp_query like this: <?php ...
1
vote
4answers
73 views

How to limit the number of post that WP_Query gets?

I have been researching on Google and WPSE and the only thing I see repeatedly is to use showposts, that is deprecated. I am familiar with WP_Query, and I thought that if I set posts_per_page to my ...
0
votes
1answer
635 views

SELECT * FROM $wpdb->posts WHERE ID > 160

I would like to retrieve all posts and relative tag with ID greater than 160. I tried: '$args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 5, 'orderby'=> ...
0
votes
0answers
11 views

Eliminate typical pages on search page, turn it into ajax search with “infinite” sized single page

I'm trying to change the default behaviour or WP search page, I have hidden the paging links, and added a button("more results") that sends an ajax request, but I'm not sure how to handle this ...