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.
5,753
questions
7
votes
4
answers
11k
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 ...
2
votes
1
answer
8k
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
2
answers
4k
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 ...
8
votes
4
answers
10k
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 ...
3
votes
3
answers
3k
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 ...
463
votes
7
answers
194k
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.
They all do similar things, so when should I use one over the others?
1
vote
4
answers
9k
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
2
answers
1k
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?