Skip to content
Advertisement

WordPress – List Categories Limit

I want to ask something which I don’t have any idea if its possible or not.

I will show you first as html to explain what I need.

JavaScript

As you see on the code above there are 2 <ul> elements two menus, but one is visible and one is hidden which I can display hidden-content by clicking on the button.

With the code below I can display all WordPress categories but would be nice to know if its possible to display the half of categories in the first div and the other half in hidden-content class.

JavaScript

Advertisement

Answer

Yes it is possible, and there are many ways to achieve this, probably the easiest and fastest is (this is extremely naive and I just added a few additions and modifications to your code, the concept is just find the index that is half the array length), this should work assuming your originally code works, if it doesn’t then I’m sure you can understand the concept.

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