我在WordPress网站上有一个页面,该页面会自动列出我的所有帖子标签。问题是我有很多标签,页面太长。我想将其拆分为不同的页面,例如<!--nextpage-->
。显然,我无法使用此Quicktag,因为页面内容是自动生成的。
有什么想法可以实现此功能?
//This code displays a list of all post tags
$categories = get_categories( array(
'taxonomy' => 'post_tag',
'orderby' => 'name',
'order' => 'ASC'
) );
$i=0;
foreach( $categories as $category ) {
$i++;
$category_link = sprintf(
'<a href="%1$s" alt="%2$s">%3$s</a>',
esc_url( get_category_link( $category->term_id ) ),
esc_attr( sprintf( __( 'View all posts in %s', 'mytheme' ), $category->name ) ),
esc_html( $category->name )
);
echo '<p>' . sprintf( esc_html__( '%s', 'mytheme' ), $category_link ) . '</p>';
if ($i % 40 == 0) {
// There should be a code that splits a page after every 40 tags
// something like what <!--nextpage--> does
}
}