admin管理员组文章数量:1122832
I'm using the following code in functions.php to add rel prev/next tags to paginated contents:
function add_rel_nextprev_to_paginated_content()
{
global $paged;
if ( get_previous_posts_link() ) { ?><link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>"><?php }
if ( get_next_posts_link() ) { ?><link rel="next" href="<?php echo get_pagenum_link( $paged + 1 ); ?>"><?php }
}
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
add_action('wp_head', 'add_rel_nextprev_to_paginated_content');
This works well for categories, tags and other content, but not the posts that were split into multiple pages by WP's tag.
However, I can't find the right function to call the next page of a paginated post.
Any help is highly appreciated.
I'm using the following code in functions.php to add rel prev/next tags to paginated contents:
function add_rel_nextprev_to_paginated_content()
{
global $paged;
if ( get_previous_posts_link() ) { ?><link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>"><?php }
if ( get_next_posts_link() ) { ?><link rel="next" href="<?php echo get_pagenum_link( $paged + 1 ); ?>"><?php }
}
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
add_action('wp_head', 'add_rel_nextprev_to_paginated_content');
This works well for categories, tags and other content, but not the posts that were split into multiple pages by WP's tag.
However, I can't find the right function to call the next page of a paginated post.
Any help is highly appreciated.
Share Improve this question asked Sep 7, 2018 at 0:23 TobyToby 131 silver badge6 bronze badges1 Answer
Reset to default 0After some research I found a code snippet that exactly does the job as desired.
See https://orbitingweb.com/blog/adding-next-and-prev-tags-to-paginated-posts/ for details and further explanations.
本文标签: functionsHow to add link rel tags on paginated posts
版权声明:本文标题:functions - How to add link rel tags on paginated posts? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736291044a1928641.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论