繁体   English   中英

将页码添加到分页页面上的元标题 Wordpress、Yoast

[英]Add page number to meta title on paginated pages Wordpress, Yoast

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

我无法使用 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>

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

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

return $title;
}

好的,最后我在本指南中找到了修复程序: https//edward-designer.com/web/multipage-wordpress-seo/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM