Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yoast SEO主要类别分页_Php_Wordpress_Pagination_Seo - Fatal编程技术网

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>

在上一个帖子链接和下一个帖子链接方法中,我应该写什么来代替保存帖子主要类别名称的变量