First, don’t use query_posts
. From the Codex:
query_posts() is the easiest, but not preferred or most efficient, way
to alter the main query that WordPress uses to display posts. It does
this by putting the main query to one side, and replacing it with a
new query. To clean up after a call to query_posts, make a call to
wp_reset_query(), and the original main query will be restored.It is strongly recommended that you use the pre_get_posts action
instead, and alter the main query by checking is_main_query
Second, your queries are different.
Compare the two. The query generated with those arguments– 'cat=1&showposts=-1'
— is:
SELECT
wp_posts.*
FROM wp_posts
INNER JOIN wp_term_relationships ON (
wp_posts.ID = wp_term_relationships.object_id
)
WHERE 1=1
AND (
wp_term_relationships.term_taxonomy_id IN (1)
)
AND wp_posts.post_type="post"
AND (wp_posts.post_status="publish")
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
Your hand-written query has two LEFT JOIN
s not one INNER JOIN
. Your query also has something called $childcond
— don’t know what that is. It also has conditions for a particular term_taxonomy.taxonomy
and there is no GROUP BY
.