网站标题怎样写,才能更加亲近搜索引擎?看看这个
这方法很简单,将下面的代码添加到主题的 functions.php
<?phpfunction auto_wp_title($title, $sep) {global $paged, $page;if (is_feed()) {return $title;}// Add the site name.$title.= get_bloginfo('name', 'display');// Add the site description for the home/front page.$site_description = get_bloginfo('description', 'display');if ($site_description && (is_home() || is_front_page())) {$title = "$title $sep $site_description";}if ($site_description && (is_singular())) {$title = "$title $sep $site_description";}if ($site_description && (is_tag())) {$title = "$title $sep $site_description";}if ($site_description && is_category()) {if (is_category(array('product-1', 'product-2', 'product-3'))) {$title = single_cat_title('', false) . " _ " . single_cat_title('', false) . "代理 _ " . single_cat_title('', false) . "加盟 $sep $site_description";} else {$title = "$title $sep $site_description";}}// Add a page number if necessary.if (($paged >= 2 || $page >= 2) && !is_404()) {$title = "$title $sep " . sprintf('第 %s 页', max($paged, $page));}return $title;}add_filter('wp_title', 'auto_wp_title', 10, 2);
你首先在 header.php 顶部添加如下代码
<title><?php wp_title( '_', true, 'right' ); ?></title>
