bob
bob

Reputation: 227

wordpress queries not working in functions.php

The following code, in the functions.php file is returning nothing, not even hi:

...
<?php 
wp_reset_postdata(); 
$qr = new WP_Query(); 
while( $qr -> have_posts() ) {
echo "hi"; $qr -> the_post(); 
echo comments_number('0', '1', '%');
} ?>

Upvotes: 0

Views: 803

Answers (1)

Tom&#225;s Cot
Tom&#225;s Cot

Reputation: 1013

Try this:

$qr = new WP_Query(' '); 
while( $qr->have_posts() ) {
echo "hi"; $qr->the_post(); 
comments_number('0', '1', '%');
}
wp_reset_postdata(); 

First, you have to pass at least something to WP_Query. Also, comments_number already echoes the result, so you don't need that echothere.

Upvotes: 1

Related Questions