Make Your Own Meta Title SEO Friendly Without YOAST

WordPress has provided better documentation how to coding it in CODEX section. How to call home, call permalink, get blog info  etc available there.
And I always using that codex to build any theme from HTML to WordPress easilly.
For example, to display meta titile, just use is_* codex function.

IF in home base, use is_home(),
if in category page, us is_category(),
if in single page, use is_single(),
if in page, use is_page(),
if in not found page, use is_404(),
if in search page, use is_search().

Now we combine built in function above.
Let say:

if current page is home page, echo bloginfo(‘name’)  and bloginfo(‘description’) on meta title,
if current page is category, echo single_cat_title() and bloginfo(‘name’) on meta title,
if current page is single page, echo single_post_title() on meta title,
if current page is 404 not found page, echo bloginfo(‘name’)  and words  Page not found on meta title,
if current page is search page, echo bloginfo(‘name’) and words ‘Search results for‘ and wp_specialchars($s, 1)  on meta title,

 

So, code would be like this:

<title>
<?php if (is_home()) { ?>
<?php bloginfo('name'); ?> -
<?php bloginfo('description'); ?>
<?php } elseif (is_category()) {?>
<?php single_cat_title(); ?> -
<?php bloginfo('name'); ?>
<?php } elseif (is_single()) { ?>
<?php single_post_title(); ?>
<?php } elseif (is_page()) { ?>
<?php bloginfo('name'); ?>:
<?php single_post_title(); ?>
<?php } elseif (is_404()) { ?>
<?php bloginfo('name'); ?> - Page not found
<?php } elseif (is_search()) { ?>
<?php bloginfo('name'); ?> - Search results for
<?php echo wp_specialchars($s, 1); ?>
<?php } ?>
</title>

You may also modify that codex as you wish.

Share to

Do You Know!