Javascript,Nodejs,MongodDB,WordPress,CSS,PHP

LightBlog

Friday, August 24, 2018

Wordpress loop

In this post will learn common wordpress loop which is used for fetch data from post

<?php

if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
end here:

<?php endwhile; else : ?>
<p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

PHP's alternative syntax:

<?php

if ( have_posts() ) {
while ( have_posts() ) { // check condtion having post or not

the_title(); // display post title
//
the_content() // Post Content here
//
} // end while
} // end if
?>

No comments:

Post a Comment