Created
May 21, 2018 09:03
-
-
Save obiPlabon/7cc7897ae269a596842ba1c806218621 to your computer and use it in GitHub Desktop.
WP The Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* World's simplest secondary The Loop | |
*/ | |
$posts = get_posts( $args ); | |
if ( count( $posts ) ) : | |
global $post; | |
foreach ( $posts as $post ) : | |
setup_postdata( $post ); | |
the_title( '<h1>', '</h1>' ); | |
endforeach; | |
wp_reset_postdata(); | |
else : | |
// Show something to notify there's no post | |
endif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* World's simplest The Loop | |
*/ | |
if ( have_posts() ) : | |
while ( have_posts() ) : | |
the_post(); | |
the_title( '<h1>', '</h1>' ); | |
endwhile; | |
else : | |
// Show something to notify there's no post | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment