I want to show the limited categories displaying in my post. Here is my blog page.
Kindly visit the page and give me advice how can i reduce category number displaying. I have tried with this codes but not working
<?php
// display 7 random categories
$cats ='';
$categories=get_categories('posts_per_page=5&exclude=' . $GLOBALS[asides_id]);
$rand_keys = array_rand($categories, 4);
foreach ($rand_keys as $key) {
$cats .= $categories[$key]->term_id .',';
}
wp_list_categories('title_li=&include='.$cats);
?>
Would you please try the get_categories
function in the following way?
$categories=get_categories( array(
'number' => 5,
'exclude' => $GLOBALS[asides_id]
) );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.