douliao1911 2017-01-21 03:16
浏览 71

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

I know this kind of questions has been asked many time before, I have read all post on web, none of answers meet my need.

I'm not able to add page numbers to meta title on paginated pages, including homepage and taxonomy, with yoast plugin (to avoid duplicate content with search engine).

I'm using custom meta title and description, I tried to add the tag %%page%% directly on custom meta title, but it's not working.

My theme is using the new feature: add_theme_support( 'title-tag' );

This is the head on header.php file:

<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>

Please help, there are many people with the same issue, since the change to: add_theme_support( 'title-tag' );

Any suggestion is much appreciated.

Update: In the theme there is a file: content-page.php, and looks like this:

<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条回答 默认 最新

  • douzong5473 2017-01-21 09:07
    关注

    For custom meta title, you can use yoast hook,

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

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集