Php Yoast SEO主要类别分页
我的目标是创建一个分页,当同一类别中的帖子只有一个类别时,分页会遍历它们;当一个帖子有更多类别时,分页会遍历主类别 到目前为止,我的代码是:Php Yoast SEO主要类别分页,php,wordpress,pagination,seo,Php,Wordpress,Pagination,Seo,我的目标是创建一个分页,当同一类别中的帖子只有一个类别时,分页会遍历它们;当一个帖子有更多类别时,分页会遍历主类别 到目前为止,我的代码是: <?php $wpseo_primary_term = new WPSEO_Primary_Term( 'category', get_the_id() ); $wpseo_primary_term = $wpseo_primary_term->get_primary_term(); $term
<?php
$wpseo_primary_term = new WPSEO_Primary_Term( 'category', get_the_id() );
$wpseo_primary_term = $wpseo_primary_term->get_primary_term();
$term = get_term( $wpseo_primary_term );
$cat_name = $term->name;
?>
<div class='pagination <?php foreach((get_the_category()) as $category) { echo $category->slug ; } ?>'>
<span class='prev bg'><?php previous_post_link( '%link', 'Előző hír', TRUE, $cat_name); ?></span>
<?php echo $cat_name ?>
<span class='next bg'><?php next_post_link( '%link', 'Következő hír', TRUE, $cat_name); ?></span>
</div>
在上一个帖子链接和下一个帖子链接方法中,我应该写什么来代替保存帖子主要类别名称的变量