wordpress - have_post() does return null value in wp -


i used following code in page template:

<?php while(have_posts()):the_post(); the_content(); ?> 

but nothing displayed. loop not working. i'm sure that, there sufficient information content in template page.

you should use if condition check if post exists else skip loop. make sure on error log , check exact error.

<?php wp_reset_query(); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; else: ?> <p><?php _e('sorry, no posts matched criteria.'); ?></p> <?php endif; ?> 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -