Set up The Loop with query parameters. This will override the current WordPress Loop and shouldn’t be used more than once. This must not be used within the WordPress Loop.

learn more… | top users | synonyms

198
votes
6answers
64k 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?
72
votes
3answers
40k views

When to use WP_query(), query_posts() and pre_get_posts

I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I'm a little bit ...
11
votes
1answer
3k views

Alternative to query_posts for main loop? [duplicate]

Possible Duplicate: When to use WP_query(), query_posts() and pre_get_posts I just noticed today that the documentation for query_posts() mentions some "disadvantages" of using query_posts ...
4
votes
4answers
8k views

Using WP_Query to Query Multiple Categories with Limited Posts Per Category?

I have 3 categories with each 15 posts, I want to do ONE query to the db bringing only 5 first posts for each category, how can I do it? $q = new WP_Query(array( 'post__in' => array(2,4,8), ...
1
vote
1answer
313 views

order post my meta value m/d/y format with year as included value

current order: 01/01/2013 12/07/2012 12/08/2012 . . . . 12/31/2012 ------------- 01/01/2013 should appear last My code: $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $today = ...
1
vote
2answers
426 views

Limit the post for differents custom post type in the same wp_query

I have three custom post type: books magazine videos Now i want to limit the number of post for custom post type, for example: books => 3 post magazine => 2 post videos => 1 post I used a ...
4
votes
1answer
1k views

Help to condense/optimize some working code

WordPress by default shows ALL posts to users who are Authors. I wanted Authors to only be able to see their own posts so I came up with the following code which works well. Any suggestions to ...
4
votes
1answer
2k views

Hide other users' posts in admin panel

I intended to run a multi-author site, I don't want the posts from other authors to be shown in /wp-admin/edit.php page. I managed solve this problem by the codes from this thread. The code is like ...
5
votes
4answers
16k 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 ...
5
votes
1answer
4k views

Get posts from sites in Multisite?

I'm trying to pull multiple sites posts. For example, I can pull out a single site posts by a category and total posts 10. But I'm trying to pull out both posts from two separate Multisite blogs 1 ...
1
vote
3answers
2k views

query_posts and pagination, still stuck after much research

I need to paginate some custom posts...I can’t see why but I’m getting 404’s when going to the next page. Here’s my code: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( ...
3
votes
1answer
4k views

Nested meta_query with multiple relation keys

I am curious whether Wordpress is able to run nested meta_query, with each having different relation keys? As of Wordpress 3.0, tax_query is able to perform this function; I'm wondering whether this ...
1
vote
1answer
358 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 ...
1
vote
1answer
2k views

How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling

I edited my loop in archives.php in order to work with pagination and with the Category Post List Widget. I basically pieced it all together from random code and ideas and am now so far from the ...
0
votes
2answers
245 views

how could I get the pagination as I want to when query posts using get_posts function

I am using WP3.5, and I have a post_list.php which will show all the posts order by post date DESC. Everything is ok except pagination. I have 15 posts, for test purpose, I want to every page show 2 ...
0
votes
1answer
124 views

Passing a varible from jQuery to PHP

I have a a bunch of li's that are a blog but i want to show them enlarged in a colorbox. Therefore I need to know which li I clicked so I can get that ID and use that in my query to get all the date ...
0
votes
1answer
492 views

Having trouble generating pagination links on custom query

I'm using a custom query on a page after the initial loop to list some posts from a category I'm associating with that page. Im doing this: query_posts(array( 'category_name' => $name, ...
0
votes
2answers
2k views

How to order posts by modified date without using 'query_posts'?

I have an example basic wordpress theme template here for you. First, please take a quick look at it to get an idea. <?php get_header(); ?> <div id="primary"> <div ...
3
votes
1answer
1k views

Custom Post Type “Event”: chronological list of recurring events

i'm looking for a good and easy way to have a custom post type "event" that can have multiple dates. (I have tested about 20 plugins). I think i have no problem building a metabox allowing the user to ...
8
votes
6answers
12k views

Wp get all the sub pages of the parent using wp query

Here is my code $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page','post_parent'=>$parid,'orderby'=>'title','order'=>'ASC' )); It displays ...
2
votes
2answers
7k views

Best way to load page content in Fancybox popup?

I would like to have some links which load the page content of the page they reference to inside a Fancybox popup(pages like "shipping" or "returns", mainly text content). I would create the pages an ...
-1
votes
1answer
275 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 ...
4
votes
2answers
4k views

query_posts() in function makes global $wp_query out of sync?

This has me stumped for a while already. Either I am missing something very obvious or something very not obvious. I am also not entirely sure if this has something to do with WP or purely PHP ...
4
votes
4answers
5k views

How do I exclude a custom taxonomy from the post loop

Is there a simple or easy way to exclude all posts from a custom taxonomy in the loop? I've been looking high and low, and neither SE, SO or Google seem to have a straight answer. I know it can be ...
3
votes
1answer
1k views

Display only the latest post from multiple categories

I have a jQuery slider at the top of my index.php, which works fine. The only problem is that I would like to use query_posts to only display the latest post from five different categories, and always ...
1
vote
3answers
17k views

Custom query with orderby meta_value of custom field

Aa you know, as of WP3.0 there are options for custom advanced queries, which is great. As of this, some query parameters of custom fields like meta_key, meta_value were deprecated for the new ...
1
vote
3answers
3k views

how to group custom post type posts by custom taxonomy terms

I would really appreciate if you could help me :) I'm very stuck and don't know how to proceed. I have a custom post type called event and 2 custom taxonomies registered for it: event_type with ...
4
votes
1answer
5k views

Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)

OK, so i'm messing with Custom Taxonomies for the second time and in both instances i've run into this problem where using the posts_per_page argument in either a query_posts or WP_query scenario.. ...
1
vote
1answer
186 views

How to know which one is the main query?

I just did an action on the query using pre_get_posts and it didn't work. When I removed the $query->is_main_query() it did work. So, how do you know that what is the main query. I know there is ...
1
vote
1answer
309 views

Author List page: Exclude based on last post date

I have a Author page that I built using this code and it works fine. However, I have several writers that range from frequent to one-time writers. I would like to seperate out writers that have not ...
1
vote
4answers
1k views

Wordpress Posts Out Of Order after 3.1 Update

The first posts I wrote are now showing on the homepage. After Googling, the problem is because I am using query_posts to exclude a certain category on the main loop. <?php ...
0
votes
2answers
2k views

Get posts by meta data OR title

I have a working query that calls all my posts that have a certain meta value for one of two meta keys: $term = $_GET['term']; $args = array( 'post_type' => 'some_cpt_name', 'meta_query' ...
13
votes
3answers
9k views

What are all the available parameters for query_posts?

The WordPress codex page for query_posts states that it does not cover all the parameters which query_posts takes: Parameters This is not an exhaustive list yet. It is meant to show some of ...
6
votes
4answers
2k views

Display/query post formats

WP 3.1 has everyone excited, if somewhat confused, about post formats. Enabling new post formats The issue of enabling post formats has been covered at length. It's as simple as adding this line to ...
2
votes
1answer
2k views

Loading Custom Post Type Events into jQuery-based FullCalendar?

Here is a question I have spent over 3 hours attempting to solve but each approach I take ends up not working out for me. All I am attempting to do is utilize this opensource ajax calendar script: ...
7
votes
2answers
4k views

How do I query by post format in WordPress 3.1

I am trying to query for all posts with a post format of 'quote.' I have added the post formats to my functions.php with add_theme_support( 'post-formats', array( 'image', 'video', 'gallery', 'quote' ...
4
votes
5answers
4k views

How to return results of a get_posts() in explicitly defined order

I'm trying to create a loop of explicity ordered posts, for example: <?php $args = array( 'include' => '1,3,8,4,12' ); ?> <?php get_posts( $args ); ?> The results are ...
3
votes
2answers
3k views

Sort posts alphabetically by custom field value, insert divider between different letters

i'm listing all posts of my custom post type "person" alphabetically sorted by the custom field last_name on a page. How would i insert a divider (e.g. an image of the letter) before a letter range ...
2
votes
2answers
830 views

Using categories & “stickyness” together

I've got a custom query on my homepage showing all posts in a certain category. I need this query to respect sticky posts, but it seems from my research that category queries ignore stickyness. My ...
0
votes
1answer
584 views

Help altering a query to exclude all but standard post format

I feel like I've been banging my head against the keyboard for a week with this problem. I'm trying to change my current query on my home page to show only posts that are set as standard posts using ...
11
votes
3answers
16k views

How to Get All Posts with any post status?

i am creating a frontend dashboard where i need to show all the post by the current user. So i need to show posts with all post status. Mainly published, trashed and the pending. I am now using ...
9
votes
3answers
9k views

Order by meta value or date?

Got a custom field called startDate but its only on a few events. I was wondering if it isn't set for a post I could use post_date to generate the posts list? // if meta_key _postmeta.startDate isn't ...
6
votes
1answer
9k views

How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?

I've been troubleshooting an issue over the past few days and keep going in circles. Could really use a fresh pair of eyes to help me answer this question... So I'm working with a wordpress site ...
5
votes
1answer
5k views

Using meta_query, how can i filter by a custom field and order by another one?

With the following code (in functions.php) my posts (of CPT event) are ordered by _end_date instead of _start_date. What's the proper solution to this as of WP 3.1.3? Of course I'd like to avoid using ...
2
votes
3answers
1k views

How to get the parent's taxonomy?

I have 2 customs post type : "Artist" and "Concert", the "Concert" custom post type is the child of the "Artist" custom post type, the "Artist" custom post type has a "genre" taxonomy. What I'm ...
0
votes
2answers
364 views

List users with the most total posts view

I'm asked by my friend to create a widget for his multiauthor blog. He wants to list 3 authors with the most total post view from their posts. I've got the job done for the post view using post ...
4
votes
1answer
4k views

How to filter custom posts by tags and custom fields?

I'm planning a site for a client who wants users to be able to filter upcoming events by the following criteria: Type i.e. Comedy, Theatre, Music etc. Date Daily or Weekend Duration Daily or Half ...
3
votes
1answer
2k views

Filtering posts by post meta data

I want to filter posts in such a way that only posts, for which get_post_meta($post->ID, "project_cat", true) (it returns a post ID) is equal to my specified value, are shown. Any way to do this? I ...
3
votes
2answers
2k views

Custom post type archive 404's with paginate_links

im using paginate_links function to create pagination on my custom post type archives, no matter what i do im hitting 404 errors when going to view page 2 (ie clicking to go on one page in the ...
3
votes
4answers
877 views

How do I create a random post that will last for a day

How do I create a random post but it shouldnt be change when the page is refreshed I want a random post that will last for a day and after 24 hours or a day, it will change randomly the post , ...