"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

0
votes
0answers
33 views

[Solved By Pieter Goosen]Wordpress WP_Query post__in [on hold]

I try to get value from database==> postmeta ==> Meta value : value Using this code $promo_value = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_product_id' ...
0
votes
1answer
15 views

the_post() within switch_to_blog() altering my excerpt

I have a strange problem I'm facing when using WP_Query with multisite in a plugin I'm writing which hooks into add_meta_boxes. I'm wanting to display all post titles in a dropdown in a meta box. ...
0
votes
1answer
11 views

How to use filter hook posts_join for querying taxonomy terms in posts_where?

For the last few hours, I have been trying to use the filter hooks posts_where and posts_join to search for posts based on taxonomy terms, in this case, the taxonomy is 'category' and the term is ...
1
vote
1answer
25 views

How to search for posts IN OR title OR content OR author?

I have looked at many posts and questions regarding searches for custom meta, but I want to search for posts and include those if the search query matches an author name. I have come up with the ...
0
votes
1answer
33 views

WP_Query condition affects posts_per_page count

I'm trying to create a new WP_Query that displays the last 5 posts from cat 1 that doesn't have a thumbnail. This actually works: <?php $the_query = new WP_Query( 'cat=1&posts_per_page=5' ); ...
1
vote
0answers
15 views

Conflict with get_posts and the_content

I have this snippet in my header.php to display a slider: <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 6, 'meta_query' ...
0
votes
0answers
11 views

how to load posts to a custom post template after using template_redirect or template_include

I need to use the URL parameter ?m=1 to load every page of my wordpress with a different template but the problem is that I can't pull the text and posts that can be accessed using the canonical URL I ...
-1
votes
2answers
46 views

Limit the number of posts via wpquery

We suppose that a category has 1000 posts, we can use the following code to show 10 posts per page and the wp pagenavi would present 100 pages with links of above 1000 posts. <?php ...
0
votes
2answers
335 views

How to get Tags with specific post id

I have created one post and post ID is 34 and added some Tags and Now I want to retrieve all tags with post ID. Any Idea?
0
votes
1answer
431 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. ...
0
votes
1answer
18 views

wp_query with multiple custom fields

My Query is this: $products = new WP_Query( array( 'post_type' => 'ys_product', 'orderby' => array( 'date' ), 'order' => 'DESC', ...
0
votes
2answers
494 views

WP Query - duplicated posts once including tags in search results

I running WordPress on IIS & SQL server. As some of the plugins do not work correctly with DB ABSTRACTION I am using a lot of functions.php filters as so on. To make my search results include ...
0
votes
1answer
1k 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
841 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 ...
0
votes
1answer
377 views

Action hook “wp_insert_post” works but not for last imported post

I want to run a custom function whenever posts are imported to my custom post type. I am currently running this code - function on_post_import($post){ global $wpdb; $results = ...
1
vote
5answers
2k 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 ...
1
vote
1answer
45 views

convert custom query to wp_query

My query is as below $querydetails = " SELECT wposts.* FROM $wpdb->posts wposts INNER JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id INNER JOIN ...
0
votes
1answer
25 views

How to query using a combination of custom_field values?

I need to get posts pertaining to a given category, AND : have the event_start_date (custom field) greater or equal than today's date OR have a event_end date (custom field) greater or equal than ...
0
votes
1answer
762 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
452 views

Site not getting correct featured image from my query

On the home page of my site I have a series of tiles that link to various parts of the site. One tile links to the blog and I have written some code to pull the latest post with an image attached to ...
1
vote
1answer
2k views

How to create database table, add data, update and delete using wpdb via plugins?

I am just starting out to create plugins with database. I know to create a custom database when activating the plugin. I just want to know whether we can create tables at the front end like adding the ...
0
votes
0answers
14 views

Add custom WP_Query after the first 3 posts

In my main loop I want to add a custom query after the first 3 posts. I managed to do this -- code will follow -- but I have one problem: instead of adding the new posts after the third post, my code ...
0
votes
1answer
40 views

Custom Post type and Custom Field WP_Query

I am developing a site for a client who is a Youth Football (Soccer) Club, with lots of different Teams depending on the abilities and ages of the children. I have added in a Custom Post Type called ...
1
vote
1answer
284 views

Too many posts cause slow load when paginating

I have about 10k posts and I made a page that lists all posts but it is paginated every 54posts. It gives 131 queries in 6.730 seconds which is pretty slow to load. Is there a way to make it load ...
1
vote
1answer
32 views

Wrong request query on cpt and tax

In my plugin I think that I use pretty much standard and documented way to add my custom post type and two tax (cats and tags), but only thing that I do is set custom capability_type and perms. Here ...
2
votes
1answer
61 views

Related posts by author pagination not working on the production site

The code that I'm using has adapted from this example and successfully tested on my localhost but when I pass the site to a live server, the pagination crashes with wordpress permalinks set (/% ...
0
votes
2answers
425 views

Custom search: Search posts but display parent page in results

I'm using Wordpress 3.5.1 with a modified twentytwelve theme. My main site structure is based on the Smooth Slider plugin (jQuery Cycle). I have Pages that contain only a shortcode (for example, ...
0
votes
2answers
292 views

SQL returned by Wp_Query has wp_posts.ID = -1

I have a custom loop based on these arguments (below), and for some reason when it's run, the SQL returned has this fragment: ... AND wp_posts.ID = -1 ... And I get no results from the db. If I run ...
0
votes
0answers
8 views

Loop tags with specific design

Forgiveness for the title, I can not think of anything to describe it. First I have a basic loop: <?php $args = array ( 'category_name' => 'juego-de-tronos', 'orderby' ...
0
votes
2answers
502 views

Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request

This is my first attempt at modifying the main query using the pre_get_posts action/filter This is the function currently hooked to it: function advanced_product_search_filter($query) { ...
0
votes
1answer
61 views

WP_QUERY loop, offset in the arguments and the paginate_links - can these work together?

I have a page where the first 4 posts from category 7 are displayed with their own query and style. Then I have a small box were I want to display the rest of the posts from category 7 and to use a ...
0
votes
1answer
33 views

Pagination is not working on custom query inside a custom home page template

I know this is a duplicate question. But to comment on existing question, I dont have enough points. So here we go.... Pagination is not working on custom query inside a custom home page template. ...
0
votes
1answer
38 views

Meta Query querrying several post types based on ACF fields is broken after update to WP 4.1

I was using the following arguments for a WP_Query for months: $args = array( 'post_type' => array( 'posttype1', 'posttype2', 'posttype3', 'posttype4' ), 'posts_per_page' => -1, ...
0
votes
1answer
433 views

wp_query for displaying attachments with a tag

So I am running the following query: <?php $args = new WP_Query(array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'oderby' => 'title', ...
0
votes
2answers
54 views

query_posts different amount of posts per page

I have a posts_per_page query to paginate multiple post types, which works great! Now though, as it paginates it to show (in this case) 100 posts per page, I'm wondering if you can show 100 on page ...
0
votes
0answers
23 views

WordPress database error Duplicate entry 'cron' for key 'option_name' for query [closed]

Today i see the error's with my website and it seems to slow down the performace of the website when i was having very high traffic on the website. I bought Vaultpress plugin for the backup and i was ...
0
votes
2answers
600 views

Post Type => Any conundrum

I have a number of regular posts and pages in a regular category called "Featured". I have also installed a plugin called "Event Organizer" that creates its own custom post type called "Event" and has ...
0
votes
1answer
41 views

Cannot order by in WP_Query

I'm stuck with this issue : I'm having a custom query in which I cannot order by anything. I want to order by a specific meta_value. But event when ordering by name, title, date etc, I still can't. ...
1
vote
1answer
471 views

How do I create my own nested meta_query using posts_where / posts_join?

Some of my posts (not all) have a price as a meta key/value. Today I use the pre_get_posts action so that my users can search for prices that are between a certain value. This is the code that I'm ...
209
votes
6answers
71k views

When should you use WP_Query vs query_posts() vs get_posts()?

It seems like half the tutorials in the Codex and around the blogosphere use query_posts() and half use WP_Query. What's the deal?
2
votes
1answer
321 views

Display recent posts from the same category as current post in sidebar

I'm using a modified version of Twenty Twelve and I'm trying to display recent posts from the same category as the current post (except the current post) in the sidebar. I started this way but ...
1
vote
2answers
449 views

twentyeleven_content_nav hook no longer outputs navigation link after 3.5 upgrade

After upgrading to 3.5, I discovered that navigation has disappeared outside of the main index page. Theme is TwentyEleven and I've verified that this still occurs after disabling all plugins. ...
1
vote
1answer
30 views

No results found from a $wpdb->get_results() query when trying to join more than one meta key query

That title was a real mouthful. I have a custom post type called work with three custom taxonomies called work-client, work-type, and work-service. I'm using Advanced Custom Fields to make a nice ...
3
votes
2answers
45 views

Using WP_Query To Get Posts Randomly From today

In the logic of the data_query(); I found this WP_Query sample: <!-- Second Senses Featured --> <ul id="featuredSecond" class="featured-second"> <?php $today = ...
0
votes
1answer
21 views

Display all attached image of every post of custom post type and link to original post

I've written a loop that displays all the images that are attached to every single post of a specific post type. The post type is called "atls_events" and I'm outputting an image size called ...
1
vote
1answer
466 views

Auto Populate Custom Field with Complex Value That Increase by One?

Can somebody help me to sort this? I am using WP 3.5.2 and I have "Orders" post type where purchase_order custom field is located. This is the sample of purchase order record: POCOS20130051 PO - ...
0
votes
0answers
21 views

WP_Query is being reset after <header> tag (using chaining method)

I'm creating a page template. In this page template I create a custom query. - page-recipes.php: <?php /** * Template Name: Recepten - archief * chained with /archive-recipes.php * */ ...
0
votes
2answers
19 views

Custom Taxonomy Breaks Pages

I have a custom taxonomy called 'industry' that I want to use on custom post type 'website-design'. It works on the intended post type, but other pages are broken. I changed the 404 template as per ...
1
vote
4answers
2k views

Get count of custom post type created by current user

I'm trying to get the count of published posts in a custom post type for the current user (to display on a profile page). I found this here on the forums: <?php global $wp_query; $curauth = ...
0
votes
1answer
30 views

Filter and Order by Multiple Custom Meta Values

I am trying to query a custom post type, order by a custom meta value, and only display posts with a different custom meta value. I am able to do each independently but not both at the same time. ...