Last active
May 28, 2023 15:57
-
-
Save joshespi/be373c94c0b7fae24b427e0d374c5ae5 to your computer and use it in GitHub Desktop.
basic wordpress 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 | |
// Start “The Loop” | |
if ( have_posts() ) : // Does our website have any posts to display? | |
while ( have_posts() ) : the_post(); // If the answer is “yes”, let’s run some code. | |
the_title( '<h2>', '</h2>' ); // Let’s display the title of our post. | |
the_content(); // Let’s display the content of our post. | |
endwhile; // There are no more posts to display, let’s shut this down. | |
else : // If we don’t have any posts, let’s display a custom message below. | |
_e( 'Sorry, no posts matched your criteria.', 'textdomain' ); | |
endif; // OK, we can stop looking for posts now. | |
// End of “The Loop” | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment