"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

3
votes
4answers
5k views

Counting Posts of a Given Post Type Having a Specific Taxonomy?

(Moderator's note: The original title was "How to know the number of custom type posts having a specific taxonomy") I'm stuck with the function wp_count_posts()! I created custom post types called ...
1
vote
2answers
551 views

List Posts by Category for a Non-Zero, Non-NULL Custom Field Value?

(Moderators note: The original title was: "Need help identifying and looping through categories where posts have custom field set") I need to loop through my categories however I need to limit the ...
0
votes
1answer
765 views

Problem with WP_Query sort

I have the following custom query written for a page- $menu_loop = new WP_Query( array( 'post_type' => 'page', 'posts_per_page' => 50, 'post_parent' => 616, 'order_by' => 'post_title', 'order' => ...
0
votes
2answers
1k views

Total Count of Posts NOT in Selected Categories?

I need to get the total number of posts that are not in selected categories. I have category IDs of the categories that I want to exclude from count (in the variable $folio_cat_ids) So far I have ...
6
votes
3answers
5k views

Getting Post Comments for post ID using WP_Query() and a Custom Loop?

(Moderator's note: The original title was "Is there a way to get post comments by post ID on a custom loop using WP-Query()?") Hi! I'm running a custom loop using WP_Query, that only displays one ...
1
vote
1answer
2k views

Different Results with query('s=computer') vs get_posts('s=computer')?

I have two different pieces of code and it's returning two different results. $search_query = new WP_Query(); $search_posts = $search_query->query('s=computer'); echo count($search_posts); vs. ...
2
votes
2answers
3k views

Displaying Posts Related to Other Posts by a Taxonomy Term?

I have a custom post type for musician's profiles, and a taxonomy for their location (categorised hierachically into Countries and then Cities). On the musician's individual profile pages I need to ...
6
votes
4answers
6k views

Querying posts from multiple sites in a network?

I realize there have been a few questions which dance around the solution I am after but I believe I am looking for something specific. This is actually a two part question: 1) My goal is to have ...
2
votes
3answers
940 views

What's the best approach for showing posts by A->Z order?

I've just launched a site that has a RESOURCES section in it, listing of school, documents etc. now the client asks to add an 'Alphabetical Sorter' that will enable the users to see in each specific ...
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?
1
vote
2answers
2k views

Excluding Sticky Posts from The Loop and from WP_Query() in WordPress?

The following snippet is from a sidebar widget that lists "recent posts". Since its on the home page and I feature my lastest sticky post prominently on that page, I want to skip over the sticky in ...
5
votes
2answers
946 views

Differences Between WP_Query() and get_posts() for Querying Posts?

What are the differences between using WP_Query() and get_posts()? Which is better to use in what case and why?