WordPress wp_title blank on index page

后端 未结 12 1023
刺人心
刺人心 2020-12-24 05:44

I\'m new to WordPress and just installed version 3.3.1.

I did some googling regarding this question and found some answers but they were relevant to version 2.7 and

12条回答
  •  伪装坚强ぢ
    2020-12-24 06:02

    I use this one and it never failed:

        function pageTitle($echo){
            $title = "";
    
            global $paged;
            if (function_exists('is_tag') && is_tag()) {        
                $title .= single_tag_title(__("Tag Archive for "" , 'circle'),false); 
                $title .= '" - '; 
            }
            elseif (is_archive()) {
                $title .= wp_title('',true); 
                //$title .= __(' Archive - ' , 'circle');
                $title .= __(' - ' , 'circle');
    
            }
            elseif (is_search()) {
            $title .= __('Search for "' , 'circle') . esc_html(get_search_query()).'" - '; 
            }
            elseif (!(is_404()) && (is_single()) || (is_page())) {
                $title .= wp_title('',true); 
                $title .= ' - '; 
            }
            elseif (is_404()) {
                $title .= __('Not Found - ' , 'circle'); 
            }
            if (is_home()) {
                $title .= get_bloginfo('name'); 
                $title .= ' - '; 
                $title .= get_bloginfo('description'); 
            }
            else {
                $title .= get_bloginfo('name'); 
            }
            if ($paged>1) {
                $title .= ' - page ' . $paged; 
            }
    
            if ( !$echo ) return $title;
            echo $title;
        }
    

    Note that there are translation domains in it that you might want to change.

提交回复
热议问题