Forums

Advice creating stucture/plugin to generate a list of categories (1 post)

  1. cpayan
    Member
    Posted 3 years ago #

    I'm pretty new to WordPress and PHP, though I'm familiar with programming already, though mainly in Java for class and whatnot.

    What I'm trying to achieve here, though, is this effect

    Here, issues is the parent category, while those under it are the subcategories (obviously), and the subcategory highlighted in blue is the subcategory of the post being displayed. If they were on the category page for Issues, as it were, all the subcategories would be grayed.

    I've been reading and trying to use functions from category.php and category-template.php with very little success, and my eyes have been crossing trying to figure out if I had an object, just a cat_ID, or a string. So I'm asking for a bit of help in creating this functionality.

    What I had in mind already (but can't seem to accomplish without fatal errors abounding) was simply taking the category from the page, and finding it's parent. Since I don't anticipate there being more than 2 layers of categories, if the category has no parent, I know that it's something like "Issues" in this example, and I can just find its subs and display them all in gray.

    Otherwise, if I'm looking at a subcategory ("Poverty" and the like in the example above) then I can display the parent, then I wanted to take its children as an array and display them one by one, so I can check if any of them are the page's category. The page's category then gets displayed in blue, the rest in gray, and I've got what I want.

    I don't think the logic is wrong, I'm just at an impasse as to how to accomplish it with PHP and WordPress. Like I mentioned, I'm pretty green to both technologies, and so I wonder if it's just some fundamental thing I'm missing.

Topic Closed

This topic has been closed to new replies.

About this Topic