3

我知道这种问题以前被问过很多次,我已经阅读了网上所有的帖子,没有一个答案符合我的需要。

我无法使用 yoast 插件将页码添加到分页页面上的元标题,包括主页和分类(以避免与搜索引擎重复内容)。

我正在使用自定义元标题和描述,我尝试将标签 %%page%% 直接添加到自定义元标题上,但它不起作用。

我的主题正在使用新功能:add_theme_support('title-tag');

这是 header.php 文件的开头:

<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--  >
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--[if lt IE 9]>
<script src="<?php print get_template_directory_uri();?    >/assets/js/ie8/html5shiv.js"></script>
<script src="<?php print get_template_directory_uri();?    >/assets/js/ie8/respond.min.js"></script>
<![endif]-->    
<?php wp_head();?>
</head>

请帮助,有很多人有同样的问题,因为更改为: add_theme_support( 'title-tag' );

任何建议都非常感谢。

更新:在主题中有一个文件:content-page.php,看起来像这样:

<div class="post-header">
<h2>
<?php the_title();?>
</h2>
</div>
<div class="post-entry">
<?php the_content();?>
<?php 
$defaults = array(
'before' => '<ul class="pagination">',
'after' => '</ul>',
'before_link' => '<li>',
'after_link' => '</li>',
'current_before' => '<li class="active">',
'current_after' => '</li>',
'previouspagelink' => '&laquo;',
'nextpagelink' => '&raquo;'
);  
bootstrap_link_pages( $defaults );
?>
</div>
4

1 回答 1

0

对于自定义元标题,您可以使用 yoast 挂钩,

add_filter('wpseo_title', 'add_meta_title', 10, 1);
function add_meta_title($title){
 //add meta title

return $title;
}
于 2017-01-21T09:07:39.180 回答