• Hi all,

    I’ve got enough content on my site now to demonstrate what I’m trying to do. If you go to my site, you’ll notice that under the top markets section of my sidebar, I’ve got lists of markets. Digging a bit deeper, you may notice that these are all parents of the Airchecks category. The problem with the way this is set up currently is that every time I add a new category, I have to go in and edit my custom sidebar, adding said market’s category to the list. Is there a way to automate this so that every time I add a category as a child of Airchecks, it is added to that section of the sidebar?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • How are you currently editing the list? Is this a manually maintained list? Looks like this to me. If so, take a look at the category block: https://www.ads-software.com/documentation/article/post-categories-block/

    Thread Starter bob cavanaugh

    (@bobdavcav)

    You are correct that this is a manually maintained list currently, that’s what I want to move away from. I think I explored the category block when I first set up that list, but how would I get it to do what I need to? The documentation you linked to does not tell me whether the block can be limited to displaying only the child categories of one parent, and if so how that can be accomplished. That’s why my friend who was helping me set up the site initially and I agreed to start out with a manual list for now and I would ask here when I got to where I am now in the development of my site. I did ask about this maybe a month ago, but the response I got then required a lot of PHP editing, which neither of us were comfortable with.

    Unfortunately, what you are looking for is currently not possible with the category block. In my search, I have also not found any other block that offers this (even if it probably exists somewhere in one of the block plugins).

    As a quick solution, you could use this code that I have just created: https://gist.github.com/threadi/a58829e99e3a3c2f2dded7c50bad4644

    You would have to integrate it into your project using a code snippet plugin, for example. You only need to use the shortcode where you want the output to take place. You can find the ID of the parent category in the backend in the links when editing it (called tagID there).

    The disadvantage of this is that the shortcode does not provide the styling that a block would allow. But first see if you get along with it.

    Thread Starter bob cavanaugh

    (@bobdavcav)

    Sorry it’s taken me so long to get back to you on this. I was updating my site this evening and figured I’d try to get this working, but I don’t see where my category ID is. On the edit category screen I see name, slug, parent category, and description. Is the name the ID, or am I looking for something else?

    Its in the URL if you edit a category.

    Thread Starter bob cavanaugh

    (@bobdavcav)

    So, would I have to enter your code into my functions.php file or enter it into a code snippet plugin which will generate a shortcode?

    You must enter the code either in the functions.php of your child theme or in the field for individual PHP code in the code snippet plugin.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘only show a selection of categories’ is closed to new replies.