Skip to content

Instantly share code, notes, and snippets.

@tjkhara
Created June 14, 2021 12:39
Show Gist options
  • Save tjkhara/4811e42abdf0dc42bcad511bc3672949 to your computer and use it in GitHub Desktop.
Save tjkhara/4811e42abdf0dc42bcad511bc3672949 to your computer and use it in GitHub Desktop.
Wordpress template tags
<?php get_header(); ?>
<div id="content">
<!-- Static Front Page -->
<?php if( is_front_page() && !is_home() ): ?>
<h1>Static Front Page</h1>
<?php endif; ?>
<!-- Blog Home -->
<?php if(is_home()): ?>
<h2>I am on the blog home page only</h2>
<?php endif ?>
<!-- Page (Not Front Page) -->
<?php if(is_page() && !is_front_page()): ?>
<h2>I am a page, but not the front page</h2>
<?php endif; ?>
<!-- Single Post -->
<?php if(is_single() && !is_attachment()): ?>
<h2>I am a single blog post</h2>
<?php endif; ?>
<!-- Single Attachment (Media) -->
<?php if(is_attachment()): ?>
<h2>I am am attachment page</h2>
<?php endif; ?>
<!-- Category Archive -->
<?php if(is_category()): ?>
<h2>I am a category page</h2>
<h2><?php single_cat_title(); ?></h2>
<?php endif; ?>
<!-- Tag Archive -->
<?php if(is_tag()): ?>
<h2>I am a tag page</h2>
<h2><?php single_tag_title(); ?></h2>
<?php endif; ?>
<!-- Author Archive -->
<?php if(is_author()): ?>
<h2>I am an author page</h2>
<h2><?php the_archive_title(); ?></h2>
<?php endif; ?>
<!-- Date Archive -->
<?php if(is_date()): ?>
<h2>I am a date page</h2>
<h2><?php the_archive_title(); ?></h2>
<?php endif; ?>
<!-- 404 Page -->
<?php if(is_404()): ?>
<h2>I am a 404 error page</h2>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment