Skip to main content

Blog

  • the_post()
  • the_title()
  • the_content()
  • the_excerpt()
  • the_permalink()
  • the_author_posts_link()
  • time('Y-m-d')
  • get_the_category_list(',')
  • paginate_links()
  • site_url()

the_post()

  • Iterate the post index in the loop.
  • checks whether the loop has started and then sets the current post by moving, each time, to the next post in the queue.
<?while(have_posts()){
the_post();?>
<?}?>

the_title()

  • Display the current post title with optional HTML markup. It is accepted to use inside the WordPress Loop.
  • If the post is protected or private and you are on front-end, then "Protected" or "Private" will be displayed before the post title.
<?while(have_posts()){
the_post();?>
<h2><?the_title();?></h2>
<?}?>

the_content()

  • Display the post content. It is template tag and must be used inside the loop.
  • Besides using this function in the loop, it can be used on a single page like page.php, single.php.
<?while(have_posts()){
the_post();?>
<p><?the_content();?></p>
<?}?>

the_excerpt()

  • display a trimmed-down version of the full post content
<?while(have_posts()){
the_post();?>
<p><?the_excerpt();?></p>
<?}?>
  • displays link (URL) to the post that is currently being processed in the Loop.
  • this template tag can be used only inside the Loop of WordPress.
<?while(have_posts()){
the_post();?>
<h2><a href="<?the_permalink();?>"><?the_title();?></a></h2>
<p><?the_content();?></p>
<?}?>
  • Displays an HTML link to the author page of the current post’s author
<p>Posted By <?the_author_posts_link();?></p>

the_time()

  • Display the time at which the post was written.
<p>Posted On <?the_time('Y-m-d');?></p>

get_the_category_list(',')

  • returns a delimited (e.g. comma-separated) lists of categories, as part of a post entry meta.
<p>Posted On <?echo get_the_category_list(',');?></p>
  • Retrieves paginated links for archive post pages.
<p><?echo paginate_links();?></p>

site_url()

  • Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.
<p><?echo site_url('/blog');?></p>