Wordpress variable title tag

/ Published in: PHP
Save to your folder(s)

A simple set of conditions to get dynamic title tags in a wordpress template.

Copy this code and paste it in your HTML
  1. <title><?php bloginfo('name');?> - <?php if(is_home()):?><?php bloginfo('description');?><?php endif;?><?php if(is_category()):?><?php single_cat_title();?><?php endif;?><?php if(is_single()||is_page()):?><?php the_title();?><?php endif;?></title>

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.