Skip to content

Instantly share code, notes, and snippets.

@LeanSeverino1022
Last active April 5, 2020 04:19
Show Gist options
  • Save LeanSeverino1022/d6c70efb1245815e7ec07ff32699c0a5 to your computer and use it in GitHub Desktop.
Save LeanSeverino1022/d6c70efb1245815e7ec07ff32699c0a5 to your computer and use it in GitHub Desktop.
[THe Famous Loop in WP] #wordpress

THe Famous Loop in WP - heart and soul of WP

page, index, and single php files all have one very important thing in common and that is they all use the famous loop

  while (have_posts()) {
      the_permalink()
      the_post()
      the_title()
      the_content()
  }

sample index, single, or page php file

	
  <?php

      get_header();

      while(have_posts()){
          the_post(); ?>

          <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
          <?php the_content(); ?>
          <hr>
      <?php }

      get_footer();
  ?>

  <?php get_footer() ?>



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment