Questions tagged [wp-query]

"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 global variable that holds the main query object prepared by WordPress based on a given request.

Filter by
Sorted by
Tagged with
0 votes
2 answers
4k views

Loop with break in the middle

I'm trying to create a gallery type page which shows one post thumbnail from each post category. The trouble is that I want to display the page title and a link to the portfolio page in the middle of ...
mantis's user avatar
  • 780
1 vote
2 answers
2k views

Filtering WP_Query

I'm developing a site that uses a Artist custom post type and I need to query all posts of this type in a page template. I need to set the is_post_type_archive property to true too to filter this ...
leemon's user avatar
  • 1,898
1 vote
1 answer
2k views

Blogroll - Different layout for first post

I would like to have my main blogroll show 10 posts per page, but the first post of each page to be setup on a different div above the rest and have a featured image. This is what I sued for the ...
Nicholas Aguirre's user avatar
0 votes
1 answer
970 views

Getting grandchildren of a post with a specified custom taxonomy?

I have an hierarchical custom post type called Geographies, wherein each Geography is assigned to a custom taxonomy (geographytype): Area, Country, Region or City. The hierarchy is set as follows: ...
indextwo's user avatar
  • 441
1 vote
3 answers
5k views

Get all posts without tags

I'm working with a tag plugin. Is there a WordPress way to get_posts or query all posts that have no tags? EDIT I had already queried the WP Codex, search Stackexchange and Google for a related ...
Poe's user avatar
  • 241
0 votes
3 answers
96 views

Passing additional variables to a query

How can we add more arguments to an existing query? Suppose I have in my theme if (!$blog_query) $blog_query = $wp_query; while( $blog_query->have_posts() ) : $blog_query->the_post(); AND I ...
Manish's user avatar
  • 1
0 votes
1 answer
66 views

How to create single page site in WordPress

I have total 5 pages on my website, I want to display all pages as single page. It is possible? Example: http://yaremchuk.ru
Nikunj Jagad's user avatar
2 votes
2 answers
1k views

Paginated Taxonomy Term Archive including one post per term

I have a custom query which gets all the custom taxonomies for the custom post type and displays the latest post in each. At the moment it pulls in all the taxonomies. Is there a way I can limit the ...
jasonbradberry's user avatar
2 votes
1 answer
2k 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 ...
PappApp's user avatar
  • 23
1 vote
1 answer
3k views

Creating arguments from loop for WP_Query meta_query

I'm trying to create a WP_Query with the outcome arguments such as: $args = array( 'post_type' => array( 'post', 'custom' ), 'meta_query' => array( 'relation' => 'AND', ...
SomeRandomDude's user avatar
0 votes
1 answer
248 views

Taxonomy Parameters in WP Query to get posts from two different taxonomies

For example I have custom post type Cars and two custom taxonomies Brand (with terms BMW, Honda, etc.) and Color (Red, Green, etc.). Car must has Brand but may not have Color. So it may be like: Car ...
Alexander's user avatar
1 vote
0 answers
141 views

Possible to filter custom post type with multiple meta data?

I'm wondering if it's possible in one loop to accomplish what I need to do. What I would like is to sort all custom post types by the meta data of county and put them in order which it is doing here. ...
graphical_force's user avatar
0 votes
1 answer
222 views

Wordpress Query showing multiple titles

I have written a query to display in a jquery slider (nivo) however it appears that it is showing all the posts and not just one at a time This is my code: <div class="slider-wrapper theme-...
Kirsty Marks's user avatar
0 votes
4 answers
3k views

Query Posts by date range with fixed beginning and end

I need to get posts from a certain timeframe. I am using the posts_where filter. I want to specify a beginning date and an end date. This is the function I use: function filter_where( $where = '' ) {...
user998163's user avatar
0 votes
1 answer
734 views

Query_posts works when appending via AJAX call wp_query doesn't?

I'm appending some posts on a click event to a twentyeleven child theme. For some reason though it only works when I use the query_posts loop and not a wp_query loop. For instance here's my wp_query ...
UzumakiDev's user avatar
0 votes
1 answer
708 views

Using rewind_posts for displaying multiple categories

My goal is to display 5 different categories that is randomly arranged. I would like just to call them in one wp_query to lessen the load. My problem is the loop seems to be not showing the conditions ...
Jayson Pimentel's user avatar
1 vote
1 answer
1k views

Undefined WP_Query::has_posts()?

This must be wrong. I was testing something so I did: $queried_post = new WP_Query(array('posts_per_page' => 5, 'offset'=> 1, 'category' => 1)); var_dump($queried_post->has_posts()); ...
TheWebs's user avatar
  • 1,095
0 votes
2 answers
2k views

Multiple queries on Home Page - page load/site speed issue

I acquainted a client who designed his own fashion magazine site. My company handed the project to me to make it with WordPress. When I was making the complete template for the site, I found his ...
Mayeenul Islam's user avatar
1 vote
1 answer
1k views

Better to make new wp_query or only modify main query each time?

I have a theme where I need multiple queries for each column. Is it better to modify the main query with pre_get_post and reset the loop or create a new query for each of my columns?
user avatar
0 votes
1 answer
1k views

How to filter multiple queries with search?

My theme has two columns, each column has it's own query. When I do a search on my theme, it only filters the main query and not my secondary query that is on my second column. How do I do that?
user avatar
0 votes
1 answer
890 views

Looking for a way to exclude frontpage and nav menu from query filter

maybe I'm thinking about this the wrong way, but I need to: A) exclude posts in queries site-wide (minus frontpage and navbar) based on a comparison with a meta_value, and B) orderby a differnt ...
sosukeinu's user avatar
  • 191
0 votes
1 answer
6k views

how to fire join query with post_meta

I have print sql query that runs within 'posts_where' filter and its like: SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'shop_order' AND post_date >= '2013-08-26' AND ...
Er.KT's user avatar
  • 125
0 votes
3 answers
3k views

custom query to get posts

I want to create custom links like mydomain.com/custom_page/cat=ABC&tag=XYZ So that when a user clicks on the link s/he can see all posts in the category 'ABC' having tag 'XYZ' For this I've ...
Gaurav Srivastava's user avatar
2 votes
1 answer
3k views

Only display authors who have posts

I am using the code below to display all authors and their posts (in a custom post type called "publication"). This works, however it also lists users who do not have posts. How can I adapt this code ...
LBF's user avatar
  • 529
0 votes
1 answer
953 views

Query to get last posts from authors of blog

Firstly I get user with role "author". $author_args = array( 'role' => 'author' ); $authors_list = get_users($author_args); Nextly I reform array $author_list = array(); foreach((array)$...
okonik's user avatar
  • 91
1 vote
3 answers
3k 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 = ...
Paul's user avatar
  • 2,150
1 vote
2 answers
2k views

Tell wordpress to show a single page instead of an archive

So I have multiple custom parameters in the url, and at some point when the query reaches 3 parameters (e.g. index.php?post_type=foo&<param-1>=<val-1>&<param-2>=<val-2>&...
somebody's user avatar
0 votes
0 answers
1k views

Pagination in custom loop [duplicate]

I thought I know how to add pagination to a custom loop and I've seen these questions and tutorials: Pagination not working with custom loop http://weblogtoolscollection.com/archives/2008/04/19/...
Paul's user avatar
  • 2,150
2 votes
2 answers
110 views

How to show in search results posts with a particular tag in a particular category?

As the home page of my blog I've a static page. There I want to show the navigation of the site. Category1 Sub-Category1 tag1, tag2, tag3 Category1 Sub-Category2 tag1, tag2, tag3 Category2 Sub-...
GrSrv's user avatar
  • 121
3 votes
1 answer
4k views

JSON: schedule creation of json file

After some research I've managed to create a json file which I use as input for Twitter's typeahead (prefetch). On my website I have several hundreds of events and several thousands of artists (both ...
eskimo's user avatar
  • 446
0 votes
1 answer
909 views

Why doesn't my WP Meta Query return any results?

Is it not OK to accept a value from $_GET as the key in a WP Meta Query? I'm not sure why this code doesn't return any results... BOTH the queries for Price as well as bedrooms do not return any ...
kuchikoo's user avatar
0 votes
2 answers
7k views

How to use if($wp_query->query_vars['name'] == 'pagethatdontexist') without getting a 404? How to suppress 404

i want to do something if my url is /pagethatdontexist But I dont want wp sending 404 headers. I tried this: add_action('wp', array($this,'awp')); function awp(){ global $wp_query ; debug($...
Doug Cassidy's user avatar
0 votes
1 answer
124 views

Paged within a custom content type template [duplicate]

I'm having a huge problem a custom query within a custom post type template with regards to pagination. For some reason, the previous post, next post links are showing blank. If I do "www.domainname....
Troy's user avatar
  • 237
2 votes
1 answer
3k views

How to filter by custom post type in taxonomy archive pages

I have two custom types. One called "Questions" and other called "Files". They both share a custom taxonomy called "Types". Everything works fine, however if I go to the "Types" link inside my ...
Johann's user avatar
  • 867
1 vote
1 answer
1k views

Storing query variable and then using wp_reset_query

I want to use a pagination function with a custom posts query (to get posts from a specific category). My pagination function gets the query from global $wp_query; So in the following code I have ...
jay's user avatar
  • 61
0 votes
0 answers
367 views

show/hide attachments

Is there a way to show/hide attachments in my case images on a post. What I want is to mark an image as "hidden" and then only show it to the admin and hide hidden images from a normal user I know ...
Jester's user avatar
  • 101
3 votes
1 answer
1k views

Can I specify post__in for one particular post type in the query?

I want to do something like this $query_args = array( 'post_type' => array( 'cpt_1', 'cpt_2' ), 'post__in' => array( 1, 3, 5, 7 ) ); where I can specify which post type the post__in ...
djb's user avatar
  • 2,250
0 votes
1 answer
941 views

Multiple Query_Posts

I am trying to put a query_posts inside a WP_query. Anything after my query_posts doesn't work properly. Here is my code. What am I doing wrong? <?php $args = array( 'post_type' => '...
justinedelson's user avatar
5 votes
1 answer
19k views

How to check if a WP_Query has data

I have the following WP_Query, which works great: <h4>Frequently Asked Questions</h4> <ul class="faq"> <?php $args = array( 'post_type' => 'questions', '...
Johann's user avatar
  • 867
1 vote
1 answer
2k views

Ajax load more button in Recent posts widget

I create Recent posts widget and i trying to create load more button for it to get more Recent posts links by ajax ,is there any tutorial for how to make it?
Mohamed Badawy's user avatar
0 votes
1 answer
409 views

Problem while filtering by 'category_name'

I have the following code in order to display a custom WP_Query: <ul> <?php $args = array( 'post_type' => 'preguntas', 'posts_per_page' => 50, 'category_name' => '...
Johann's user avatar
  • 867
0 votes
1 answer
3k views

custom post type paging not working past page 3

I have a custom post type called services which has 23 custom posts, i also have a custom taxonomy for all the categories (5 categories). I am trying to create a list of all the custom posts of ...
asaunders's user avatar
  • 251
3 votes
2 answers
4k views

posts2posts query using connected_items array issue [closed]

My setup is as follows I hava a custom post type named 'events' and a custom post type named 'genres' which I link with scribu's Posts2Posts plugin. Each event can have multiple genres linked to it. ...
eskimo's user avatar
  • 446
0 votes
0 answers
220 views

query by meta value then date and not empty meta value

So i have a query like this function filter_where( $where = '' ) { // posts in the last 7 days $where .= " AND post_date > '" . date('Y-m-d', strtotime('-3 ...
Goran Jakovljevic's user avatar
1 vote
2 answers
3k views

Show selected images on top in Media Manager

I've searched numerous StackOverflow and Wordpress Awnsers questions, but I couldn't find any solution that matches my situation or even remotely points me in the right direction. I have a custom ...
Ogier Schelvis's user avatar
1 vote
2 answers
799 views

How can I get the first 50% of all posts (within a custom post type)?

I'm trying to make a multi column layout. Seen as CSS3 adoption of column layouts is still thin on the ground, I was thinking maybe I could grab the first half of all my posts (and then the second), ...
josh's user avatar
  • 454
1 vote
1 answer
979 views

Query multiple meta values

I'm working on a 'checkbox filter' to query posts by checked values. See this link (EDIT: As you can see there are just 2 posts in this link, as soon as the user checks for 'MINI' it gets a good ...
Trekdrop's user avatar
  • 245
1 vote
2 answers
4k views

Query based on custom fields start and end date

I have a custom post type called Events, with 2 custom fields, start date and end date. These fields are stored using a timestamp in the database. I want to create a custom query based on these 2 ...
passatgt's user avatar
  • 3,338
1 vote
1 answer
9k 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 ...
vickythegme's user avatar
0 votes
1 answer
2k views

Compare "Main" post ID to ID inside wp_query loop

I have a video viewing section on my site. The single post template displays a large area where the video plays and then there's a column of thumbnails representing other videos along the right side. ...
Eckstein's user avatar
  • 1,099

1
88 89
90
91 92
115