Skip to content

Instantly share code, notes, and snippets.

@harishkotra
Created April 3, 2017 01:39
Show Gist options
  • Save harishkotra/b05a1a5c8bba2ff0051e41b706ec4736 to your computer and use it in GitHub Desktop.
Save harishkotra/b05a1a5c8bba2ff0051e41b706ec4736 to your computer and use it in GitHub Desktop.
Generate Perfect WordPress Title Tags without a Plugin.
<title><?php if (function_exists('is_tag') && is_tag()) { echo 'Tag Archive for &quot;'.$tag.'&quot; - '; } elseif (is_archive()) { wp_title(''); echo ' Archive - '; } elseif (is_search()) { echo 'Search for &quot;'.wp_specialchars($s).'&quot; - '; } elseif (!(is_404()) && (is_single()) || (is_page())) { wp_title(''); echo ' - '; } elseif (is_404()) { echo 'Not Found - '; } if (is_home()) { bloginfo('name'); echo ' - '; bloginfo('description'); } else { bloginfo('name'); } ?></title>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment