"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
0answers
9 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 ...
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
43 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
23 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
761 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
36 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
283 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
28 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
58 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
30 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
432 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
53 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
21 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
38 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
467 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
320 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
28 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
42 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
20 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
462 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
27 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. ...
1
vote
1answer
347 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 ...
13
votes
6answers
11k views

meta_query with meta values as serialize arrays

I'm working on a project in which I'm creating a custom post type and custom data entered via meta boxes associated with my custom post type. For whatever reason I decided to code the meta boxes in ...
0
votes
1answer
18 views

Use custom get results query to show posts WordPress

I have this code before to show posts. $query_args = array( 'post_type' => 'post', 'posts_per_page' => 4, 'meta_key' => 'Views', ...
0
votes
2answers
331 views

wp_query within function within wp_query

I have a query which looks like this: $args = arguments for the query $query = new WP_Query($args); while ($query->have_posts()): $query->the_post(); $post_id = get_the_ID(); echo ...
0
votes
1answer
20 views

Find only those galleries with images

Is there a way in WordPress to use WP_Query and retrieve posts/galleries that have more than 0 metavalues with the key _gallery_image_ids? Essentially I don't want to display galleries that have no ...
0
votes
1answer
19 views

2 queries with counters

I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items ...
0
votes
1answer
42 views

Search (Custom Form, Custom Search Result)

If I have a form: <form class="search" action="<?php echo site_url(); ?>/page-search?category=2" method="get"> <input type="text" required name="search" placeholder="Search"> ...
2
votes
1answer
18 views

WP_Query search custom posts meta date fields

I have a custom post type which stores dates in a meta field as 2014-02-22 22:38:00 I can use WP_Query to find posts created in a certain month / year $args = array( 'post_type' => ...
0
votes
1answer
302 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 ...
1
vote
1answer
57 views

Overwriting posts_per_page in new WP_Query

I've tried for hours for a solution to this. Here's the problem, I have a theme that is using new WP_Query to set up a loop. That works fine. I want to take the original query, modify it, and then ...
0
votes
1answer
423 views

WP_Query post at custom position

Lets say I have a custom query which based on two custom post types: $wp_query = new WP_Query(array( 'post_type' => array('post-type-1', 'post-type-2'), 'post_status' => ...
0
votes
1answer
46 views

New WP_Query not isolating custom post types on front-page template

This is the code for my front-page.php template <?php add_filter( 'genesis_markup_site-inner_output', '__return_false' ); add_filter( 'genesis_markup_content_output', '__return_false' ); ...
0
votes
1answer
645 views

wp_query orderby random do not repeat infinite scroll - one loop

I have found a lot of documentation on solving this issue with multiple loops, I'm finding it hard to see a solution for one custom loop. Problem: I'm using infinite scroll to load in the next page ...
1
vote
2answers
26 views

wpdb custom post_type problem

I want to use custom post type in my custom SQL query, but, when I add the custom post type im my query, I get no results. Where's my probelm ? This is the code I've tried $top5_ov_performance = ...