0
這裏的示例代碼:如何在wordpress中手動生成自定義標題標籤?
<title>Reviews <?php wp_title();?><?php echo " (".get_post_meta($post->ID, 'imdb_year', true).")"; ?></title>
,我如何正確之上創建wp_title()函數?
這裏的示例代碼:如何在wordpress中手動生成自定義標題標籤?
<title>Reviews <?php wp_title();?><?php echo " (".get_post_meta($post->ID, 'imdb_year', true).")"; ?></title>
,我如何正確之上創建wp_title()函數?
這將改變標題。
add_filter('pre_get_document_title', 'change_the_title');
function change_the_title() {
return 'The expected title';
}
所以基本上你可以添加額外的邏輯裏面改變特定頁面,類別,post_types等。
Wordpress 4.4+: wp_title filter takes no effect on the `<title>` tag