Yoast SEO主要类别分页

时间:2016-09-30 15:54:37

标签: 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 = 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>

在previous_post_link和next_post_link方法中,我应该写什么而不是变量witch保存帖子主要类别的名称?

0 个答案:

没有答案