Skip to content
Advertisement

Display only 10 List Items using PHP?

I have built a subcategory widget, which pulls all subcategories from a parent cat ID and displays them as list items. I only want to display 10 list items and beyond that, display a “view all” link that links back to the parent cat ID. How can I accomplish this using my front end code below?

JavaScript

Advertisement

Answer

First, your HTML is not in the loop. Second, just increment a counter and check for 10 and break:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement