Kannan
Kannan

Reputation: 347

how to set category list limit?

I am display post category child list.list display all i need display only 6 (child ) help with us...

ex: menu (parent) list1 (child) list2 (child) list3 (child) list4 (child) list5 (child) list6 (child) list7 (child) list8 (child)

<?php $article_categories = get_categories(array(
                                    'child_of' => get_category_by_slug('work')->term_id
                            ));
    $talentChildren = get_categories(array('child_of' => get_category_by_slug('talent')->term_id));


 ?>
    <?php if ( have_posts()) : ?>
        <?php $talent_Children = array($talentChildren[0]); ?>
        <?php foreach($talent_Children as $talent): ?>
        <?php
        $talentSubChildren = new WP_Query();
        $talentSubChildren->query(array('category_name' => $talent->slug));
        ?>
        <h2><a href="<?php the_permalink() ?>talent/directors/"><?php echo $talent->name; ?></a></h2>
        <ul>
        <?php while ($talentSubChildren->have_posts()) : $talentSubChildren->the_post(); ?>
        <li>
        <h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
        </h4>
        </li>
        <?php endwhile; ?>
        </ul>
        <?php endforeach; ?>
        <?php endif; ?>
        </div>

Upvotes: 4

Views: 6578

Answers (1)

Bhumi Shah
Bhumi Shah

Reputation: 9476

You can user number =6 in get_categories function like

$talentChildren = get_categories(array('child_of' => get_category_by_slug('news')->term_id,'number' => 6,'hide_empty' => 0));
foreach($talentChildren as $talent):
    echo "<pre>";
    print_r($talent);
    echo "</pre>";
endforeach;

Upvotes: 6

Related Questions