Skip to content

Instantly share code, notes, and snippets.

@salmanbd96
Created August 7, 2015 19:46

Revisions

  1. salmanbd96 created this gist Aug 7, 2015.
    16 changes: 16 additions & 0 deletions How to Dynamic post title
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@

    Adding this code to your wordpress theme will dynamically create a title.
    <title><?php
    if (is_home()) { echo bloginfo('name');
    } else if (is_404()) {
    echo '404 Not Found';
    } else if (is_category()) {
    echo 'Category:'; wp_title('');
    } else if (is_search()) {
    echo 'Search Results';
    } else if ( is_day() || is_month() || is_year() ) {
    echo 'Archives:'; wp_title('');
    } else {
    echo wp_title('');
    }
    ?></title>