首页 文章

将页码添加到分页页面上的元 Headers Wordpress,Yoast

提问于
浏览
3

我知道很久以前就已经问过这类问题,我已经阅读了网上的所有帖子,没有一个答案符合我的需要 .

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

我正在使用自定义元 Headers 和描述,我试图直接在自定义元 Headers 上添加标签%% 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>

2 回答

  • 0

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

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

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

相关问题