"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
1answer
327 views

Display upcoming Events for next 7 Days

I saw a request for a simple 7 day event calendar that always starts with today. I have a custom meta box called opening-time that gets a YYYY-MM-DD input. For now this is what I have, and its not ...
1
vote
1answer
539 views

Thumb rating for wordpress - top user

I am currently using gd star rating (thumb rating) to rate posts (articles - no rating on comments). What I really want to do is show a table of the top 5 users and their number of votes based on the ...
0
votes
1answer
262 views

Fastest way to fetch posts across a multisite

What's the fastest way to fetch posts/content across a multisite? I had been using SimplePie RSS feeds, but I'm now investigating switch_to_blog(). As switch_to_blog appears to be quite simple to use, ...
0
votes
2answers
2k views

Having a variable based on $post_count increase when i move to the next page of results

I couldn't figure out the best way to write the title, so first of all I hope you understood what i was trying to get across. I have a snippet of code on my template page that fires after the wp_query ...
0
votes
1answer
295 views

Catergory args causing loop not to show

this has taken up most of my afternoon, but i just cannot get it to work properly. The issue is when i try to add a catergory argument to my custom loop, whether it is an include or exclude. When i ...
0
votes
1answer
443 views

Use premade array as categories in wp_query?

I have a theme options panel that the user can set which categories they want to use which is then saved as an array $blog_cat[0] etc. They can select as many categories as they want for the array ...
0
votes
1answer
574 views

Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?

Ok, this may be a bit confusing but here goes... Im working with several custom queries on the same page throughout my site. Some queries are grabbing regular post data, others are fetching CPTs ...
5
votes
6answers
12k views

Display all posts in a custom post type, grouped by a custom taxonomy

I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called “member” and my custom taxonomy is called “member_groups”. I want to list all the ...
0
votes
1answer
1k views

Post order by custom fields

<?php query_posts( 'cat=16'); ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php print_custom_field('time'); ?> ...
1
vote
2answers
1k views

Meta box dropdown of custom posts

I am trying to display a dropdown select metabox on the "add new" page of a custom post type which displays a drop down list of titles from a separate custom post type ( it's an effort to relate the ...
0
votes
1answer
764 views

WP_Query and pagination AGAIN?

I am using the WP_Query class to retrieve some posts according to variables set in url. All working well until we get to paging. The second page (though having posts - tested it by making paged => 2) ...
0
votes
1answer
568 views

WP Query get only 1 post (sticky, not sticky etc)

I'm using WP Query & want to only return 1 post in a category. Either the most recent sticky else the latest post. Is this possible? Thanks, George <?php $category1 = new ...
0
votes
2answers
553 views

WP Query and multiple pages

Can anyone tell me why this isn't working? Assuming two things here - 1. WP Query handles multiple page requests, and 2. doesn't need a reset because I'm creating a new WP Query. What happens is I ...
0
votes
1answer
3k views

Create a list of recent Custom Post Types posts

I've been using this snippet to generate a list of recent posts from particular categories in a widget. I'm currently restructuring the site using custom post types and taxonomies and want to ...
1
vote
1answer
387 views

WP_Query on custom taxonomy works fine but fails if run through wp_ajax_

I'm using WP_Query to collate some info about posts based on their custom taxonomy. My arguments are as follows: $args = array( 'posts_per_page'=> -1, 'post_status' => 'publish' ...
1
vote
1answer
362 views

Search breaks when querying main loop for category

In my theme I provide an option for users to set a 'blog category' that queries and displays only posts from that category on index.php using WP_Query: $shortname = get_option('of_shortname'); ...
0
votes
1answer
97 views

How to update custom field of a posts in a particular category

I have a lot of posts under category 'tution', which has custom field called 'video'. i need to update the 'video' value with same youtubeurl i.e all post would have the same value in the custom field ...
0
votes
3answers
5k views

WP-PageNavi gives me a 404 when using WP Query

I see that there are a lot of similar questions here at WPSE, and I've tried many of the suggestions mentioned trying to solve my problem but with no success. I have a category called News. In this ...
0
votes
2answers
114 views

How to querry for an item that saved in an array?

I know how to write querry args for WP_Query if it's a single key : for example, if query posts with the metakey of 'type'-- $query_args['type'] = (array)$type; Now, the problem is-- the item I ...
0
votes
2answers
495 views

Custom post type pagination error

Another one of these paging errors you see here so often. I searched high and low for a fix but have come up with nada so far. I am paging CPT results using my archive-{$post_type}.php template and ...
1
vote
0answers
182 views

How to make pagination work not for a whole category but for a part of it? (WP_Query) [closed]

In my example you can see that i have to paginate posts from category 6 with meta_value='izhs' for meta_key='dachaizhs' Now it works like it paginates the whole category, and then exclude from each ...
0
votes
2answers
8k views

WP_query and pagination?

I have to get some custom post types and need to do that with WP_Query (query_posts doesn't work). How can I do the pagination? Whatever I tried didn't work... any help would be awesome I can't crack ...
0
votes
1answer
2k views

Problem with 'post__not_in'

I am running a custom query below each post, to get other post from its category. Now I want to exclude the current post. This is my Query: <?php // related_posts(); $exclude_post = ...
1
vote
2answers
17k views

Get post count of current loop when using multiple queries on one page

I'm trying to get a count of the current posts inside of a loop. I'm using multiple loops on one page in my theme. So far I have: $my_post_count = $wp_query->post_count; But when I print ...
1
vote
2answers
227 views

Tricky WP Query

I am trying to use wp_query (or another native Wordpress query class) to do the following: get all posts WHERE ( post_type = 'post' AND category = 7 ) OR ( post_type = 'case-studies' AND meta_key = ...
3
votes
1answer
3k views

Overriding The Loop with filter or hook

I'm trying to replace the $wp_query object for a specific category, without having to deal with creating a new template and creating a new WP_Query object there. My aim is to change the data ...
0
votes
1answer
103 views

How to refine WP-Query with further criteria

I have a WP-Query which I pass post IDs to via 'post__in' => explode(',', $my_ids) I then want the ability to refine this list by a custom field value (if present). I have tried including the ...
3
votes
3answers
5k views

How to use a custom post type as front page?

I would like to set a site's front page to be a single post from a custom post type. I have been able to alter the request for my front page to a Custom Post Type archive with the following code ...
0
votes
1answer
203 views

How to apply the 'current_page_item' class to an archive page in `wp_list_pages()`?

So I have the following custom wp-query working on my site: function custom_front_page($wp_query){ if($wp_query->get('page_id')==get_option('page_on_front')){ ...
8
votes
4answers
3k views

How to use a custom post type archive as front page?

I'd like to use a custom post type archive as a site's front page, so that http://the_site.com/ is a custom post type archive displayed according to my archive-{post-type}.php file. Ideally I ...
0
votes
1answer
441 views

Wp-query causing problems with the_content();

I'm using some code provided in an answer on here to calculate "post X of Y" and display pagination icons on single.php. It works beautifully but it's causing problems displaying the_content(); On ...
3
votes
1answer
115 views

Why is WP-Query spelled like it is?

I'm new to PHP and WordPress, and I'm curious: Why is WP-Query capitalized like it is? Is this a PHP naming convention, based on the type of query? Or what? Thanks.
1
vote
1answer
2k views

Wordpress pagination showing same posts on each page

I need to make adjustments to a horribly written WP theme that (a custom theme that was written in tables, and bad code). The theme has several custom templates, but pagination wasn't used and ...
0
votes
1answer
3k views

wp_query order by title

I have post titles which begin with a price, eg: $199,900 - 123 Street. I am using the code below, and I'm unable to get the order by title ascending to work properly. Any suggestions please. ...
0
votes
1answer
569 views

how do I write this wp_query select statement?

I would like some help in creating a SQL statement that will query my WordPress database and return results based on search terms a user enters. Basically it would be like this. User term 1 (general ...
7
votes
1answer
20k views

WP_Query - Order results by meta value

I've checked around and haven't seen an answer which works as of yet. I have a WP_Query with the following arguements: $args = array( 'post_status' => 'publish', 'post_type' => ...
0
votes
2answers
295 views

difference between querying database and using the loop

I know this is a very general question, but I have been reading tuts on both wp Query, and The Loop, and it seems that you can go either way. Am I misunderstanding this? What I think I am reading is ...
2
votes
3answers
7k views

Page template query with WP_Query

I'd like to query only pages with a certain page template with WP_Query or a function that would return the post object, but I can't find any information about that on the officiel codex.
3
votes
2answers
3k views

How to display only top level posts in loop via WP_Query?

How do I set my custom loop to only show top-level posts? I have a hierarchical custom post type and the archive page shows both the parent and child posts.
0
votes
1answer
65 views

Query for specific taxonomy that executes a particular loop depending on volume of posts?

Is it possible to create a special wp query that looks to see how many posts exist in a specific taxonomy, or taxonomy term, and executes a particular loop depending on the volume of posts? My idea ...
1
vote
1answer
372 views

Ignoring a category in WP_Query still shows the links in next_post_link()?

So I have a WP_Query like so: $homepage = new WP_Query( 'posts_per_page=1&cat=-5' ); and in my while loop, I have a call to next_post_link() and previous_post_link(), which are both showing ...
-1
votes
1answer
282 views

Integrating custom API for post content into Admin interface & Public Website [closed]

EDITED question to be more specific and added bounty in hopes someone has a solid coded solution: So, here is an interesting task I have been trying to find a solution for. I have added a bounty ...
1
vote
3answers
11k views

How to set posts per page using WP_Query()

I'm trying to set the number of posts_per_page dynamically using my own variable. This code works fine: query_posts( $query_string . "&posts_per_page=" . $myvar ) // then display the loop using ...
4
votes
1answer
670 views

Why does `get_permalink()` produces an add. DB request without $post->filter?

I'm currently working on a custom loop/query where I need to add the permalink of a post to the array of posts I'm retrieving from the DB. Sadly get_permalink() produces one additional DB request ...
12
votes
1answer
12k views

numberposts? showposts? posts_per_page?

So the documentation on the Codex is pretty clear that showposts is deprecated. But that same documentation mentions nothing of numberposts. Instead, posts_per_page is listed. But if we turn to the ...
0
votes
1answer
369 views

Filter for replacing the WP_query object for a given category

I'm looking for a action/filter to replace replace a category archive page with the contents of a page. I'm thinking of testing the category ID, and replacing the WP_Query object with a new one ...
2
votes
2answers
1k views

“pre_get_posts” firing on every query

How can I change arguments for the main query only, and not affect other queries? add_filter('pre_get_posts', 'custom_post_count'); function custom_post_count($query){ ...
1
vote
1answer
858 views

use of 10 new WP_Query : loading too slow (with url) [closed]

i use almost 10 new WP_Query() in my main page, but the loading is quite slow : do you know what i could do for that? each "new WP_Query()" ends up with a "endwhile" : is that enough? is there ...
3
votes
3answers
3k views

Way to include posts both with & without certain meta_key in args for wp_query?

EDIT 2: Rather than figuring out the real solution I've decided to use a workaround, and am simply setting the default value for book_in_series to '0'. Thanks to @eddiemoya for all his the time he ...
0
votes
1answer
2k views

How to create a dynamic page based on form data with a plugin?

I have a form that users fill out. When they finish, they are redirected to a 3rd party site to set up payment options. After completing the payment process, they are sent back to my site with a ...