"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

8
votes
5answers
23k views

query_post by title?

is it possible to create a loop of posts using WP_Query or query_posts using the title? ie $args = array('post_title'='LIKE '.$str.'% '); $res = WP_Query($arg); // the loop... // trying this ...
0
votes
1answer
40 views

Is it possible to add query parameters on the archive page?

I have a custom post type (works), and an archive page (archive-works.php). I would like to hide the non-public posts from the archive page, so I added a custom meta box. I also modified the query to ...
0
votes
1answer
288 views

Ajax load more posts - WP_Query parameters not working

I'm trying to replace the standard WP pagination with an Ajax load more posts button. I'm basically following the code from this question which for the most part works well. Here's the relevant ...
1
vote
3answers
30 views

Not getting author rank when using return

I am implementing a section in my website to get the top 5 authors using this code. function ranked_authors(){ $usrs = get_users('role=contributor'); $countarr = array(); foreach ($usrs as ...
0
votes
1answer
29 views

Querying by taxonomy vs Querying by Custom fields Speed Comparison

I'm developing a listing portfolio for our project. (Basicaly yachts with their type, size, price, cabins, draft, build year, refit year etc.) I should filter them according to type and sort by ...
0
votes
0answers
26 views

How to make the default Wordpress search return borader results

I'm displaying the results of a search query on one of my custom pages. The query is simple: $shopArgs = array( 's' => get_query_var('s'), 'post_type' => 'products', ...
5
votes
2answers
89 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
62 views

Exclude posts that only have the 'Uncategorized' category [duplicate]

I want to exclude posts that only have the Uncategorized category (i.e. category id 1), but if a post is (erroneously) categorised as "Uncategorized" but also has other categories, I want to include ...
14
votes
5answers
29k views

WP_Query with “post_title LIKE 'something%'”?

I need to do a WP_Query with a LIKE on the post_title. I started with this regular WP_Query: $wp_query = new WP_Query( array ( 'post_type' => 'wp_exposants', ...
0
votes
0answers
53 views

WP_Query custom field pass the post id

I'm using WP_Query with ACF(Advanced Custom Fields) I'm building a news portal, and I'm trying to pass related stories from 1 post which is top_story = true. In another WP_Query I want to print the ...
1
vote
0answers
52 views

WP Query to have sticky posts first, with pagination and having a joint 'posts per page' arg with main loop

I am building a Wordpress site and have come to a bit of a wall while using a WP_Query, it started out quite simple but then sticky posts got thrown into the mix and it's becoming a bit harder to ...
0
votes
1answer
80 views

Reduce or prevent calling of update_meta_cache

My theme calls the update_meta_cache() function 58 times per page! This function appears to run the following query based on the post in question: SELECT post_id, meta_key, meta_value -> FROM ...
0
votes
1answer
96 views

Using AJAX to return search form results

I'm trying to take user input from a search form, build a query based on user input, and then return relevant posts using AJAX. Right now, the form builds the select dropdowns properly. The form ...
0
votes
1answer
33 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
10 views

alter $post variable in main query as soon as possible [duplicate]

I'm using WP with WooCommerce. For some purpose, I want to load a predefined static page (e.g. with id=5) whenever the user enters a product page (e.g. www.mysite.com/?product=my-product), by ...
5
votes
4answers
894 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 ...
0
votes
1answer
139 views

WP_Meta_Query object with conditionals

I have a custom post type (Books) that is connected with a second custom post type (People). The Books CPT has an additional author meta box that if checked, it should appear on the additional People ...
0
votes
1answer
49 views

Wp redirect to url with ampersand string

i have a url like this: www.url.ui/?keyone=valueone&keytwo=valuetwo&ekythree=valuethree stored in a variable: $url = www.url.ui/?keyone=valueone&keytwo=valuetwo&keythree=valuethree ...
0
votes
1answer
69 views

WP_Query Group by Author and Order each group DESC

I'm trying to do a query where I get all the posts from a specific category, order/group them by author and in each group order the posts DESC. In the end the author with the newest post will be a the ...
0
votes
1answer
48 views

Multiple search queries on one page

I need to display results of three different search queries on one page. More precisely, there is a searchbox on my page where a user enters a search phrase. Once the search phrase is submitted, I ...
0
votes
1answer
41 views

Display posts if specific country

I'm running a simple query that displays some posts within a custom post type. Via each post within that post type, I've added an ACF True / False checkbox. If the checkbox is ticked, I'd like that ...
0
votes
1answer
37 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
39 views

What exactly does the 's' parameter search for in WP queries?

I have a simple question, but can't find the answer anywhere. What exactly does the 's' parameter search when used in a query? Ex: $args = array( 's' => $keyword ); $query = new ...
0
votes
0answers
27 views

wpdb giving different results then query in SQL Editor

I'm trying to read candidates and the relation with expertises from 2 custom tables in my WP Database. This is my WPDB query : $candidates = $wpdb->get_results(" SELECT * FROM ...
0
votes
1answer
56 views

Wordpress page and plugin list using sql query

I want to get all published pages and activated plugins of my word press site,i want all pages and plugin using mysql query.i don't want to copy paste all pages from wp admin.i want to get this list ...
0
votes
0answers
38 views

Display taxonomy title in my loop?

I'm using a tab to display my taxonomy, I would like to be able to display a specific taxonomy (for example: sectors) from my Custom post type. But my code doesnt seem to work . . .If any body has ...
0
votes
1answer
49 views

pre_get_posts with get_posts

So in the template I've multiple featured posts and sliders and 2 default loops. I use get_posts for everything except default loops (obviously). Now the issue I'm having is excluding get_posts ...
0
votes
1answer
55 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
2answers
2k views

Display products from specific category in shop page

I know many people asked for this question but I didn't find a proper way to do it. How to add a simple meta_query (product_cat) before the execution of the shop page's query. Maybe by using a filter ...
0
votes
1answer
32 views

How to display the number of posts in a category using WP Query

Just a quick one but I am stuck in doing this. I am running a WP_Query for a category and and want to know how to display the number of posts in a category using WP Query! This is the start of my ...
0
votes
0answers
38 views

Function is creating too many queries

I have code that displays a list of categories and orders them by the number of ACTIVE posts in the category. This is determined by comparing the custom field of due date against the current date. If ...
7
votes
4answers
7k 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
1answer
27 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
22 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
33 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
45 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
32 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
27 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
26 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 ...
0
votes
0answers
18 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
53 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
votes
2answers
87 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
66 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
33 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 ...
0
votes
1answer
106 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
16 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 ...
0
votes
1answer
44 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
1answer
58 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
839 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
35 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' ...