Archived topic
Element Hook Not Working on Custom Category Archive
7 replies · Started by Olaniyi on July 6, 2021
Hi, I am trying to target the archive area of specific custom categories with hooks such as "generate_after_archive_title," "generate_before_archive_title." and " generate_after_archive_description," however, when I select the custom category archive under "Display rules," it does not work.
It works when I select "All Archives" and exclude "posts" or "post category."
However, what I need is to be able to target specific custom categories. I want to display the subcategories of each custom category in that area.
Hi Olaniyi,
The display rule you are using is not the archive page but the single post of that category.
The Nicknames is a custom post type, so you'll need to activate its archive in order to see the Nicknames category archive in the element's display rule.
You can do so in the CPU UI plugin (select true), please refer to the screenshot below:
https://www.screencast.com/t/A33YcYSixiG
Let me know if you need further assistance :)
I doubt that's the issue. I have both options; custom post and custom post category. I changed it to true anyway, and it's still not working.
Hi there,
I think you have 2 conflicting settings for your CPT. There's a manual register of CPT on your functions.php and there's a registration through CPT UI.
These two options are missing because of that - https://share.getcloudapp.com/NQuo5Gp1
I believe it's because of this part - https://share.getcloudapp.com/WnuxpPp0
But you should just remove this function entirely ask it's redundant. This is literally what CPT UI does. This code makes conflict.
This should be the display rule to set - https://share.getcloudapp.com/BluK26qQ
Thanks! The problem is solved.
Secondly, is there a code to list the subcategories of each custom post category. I am currently doing it manually.
Hi there,
maybe this will help:
https://www.wpbeginner.com/wp-tutorials/display-subcategories-on-category-pages-in-wordpress/
Thanks, David. I will check it out.
You're welcome