mercredi 9 mars 2016

Wordpress Plugin Development: having problems with the loop vs. WP_Query

I'm currently on my early steps learning in building a wordpress plugin, which basically outputs posts. I'm using it with a shortcode on a page.

I'm having the following problem:

I can get the loop working by writing:

$args = array( "posts_per_page"=> 10 );
$newQuery = new WP_Query( $args );
if($newQuery->have_posts()) {
    while( $newQuery->have_posts()) {
        $newQuery->the_post();
        the_title();
    }
}
wp_reset_postdata();

So far so good, this one is working for me, but if I use the standard loop:

if(have_posts()) {
    while( have_posts() ) {
        the_post();
        the_title();
    }
}
wp_reset_postdata();

I'm getting an infinite loop, which doesn't even post any information of the post. Am I missing something?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire