Support » Themes and Templates » Limit get_the_category output

Limit get_the_category output

  • Hi there,

    I am using a bit of code to split my post categories into two sections (only showing the child ones) and am wondering if I am able to limit the output to 3 each (just for the front page) as some posts will have many categories attached to them.

    The snippet I am using is below:

    <?php foreach((get_the_category()) as $childcat) { if (cat_is_ancestor_of(14, $childcat)) { echo '<a href="/category/',$childcat->category_nicename,'/">',$childcat->cat_name,'</a>', ' '; }}
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit get_the_category output’ is closed to new replies.
Skip to toolbar