Link to custom category not working when using the id
-
Hi
I have created a custom widget to display a custom category. The widget for my custom category works fine and in the same way that the original widget for categories.
The problem that I have is that when I select to display the custom categories in a drop down list, the links to the different items don’t work. However when they are display on a list it works.When the taxonomy is displayed as a list it generates the url as something like https://myurl/?video_category=slug where video_category is the name of my custom taxonomy and slug is the slug of the option selected. As I said in this case it works and it returns the post under that category.
When the taxonomy is displayed as a hierarchy it generates the url as
https://myurl/?video_category=id where id is a number which must be the id of the term of the taxonomy. In this case it doesn’t work and it says no posts found (however there are posts, i select the same value that works when displaying in a list). I have also checked in the database that there is a term with that id.Has anyone any idea of what can i have wrong?
In the code of my widget i have the following
location.href = "<?php echo home_url(); ?>/?video_category=" + dropdown.options[ dropdown.selectedIndex ].value
to generate the url. This is copy from the original category widget. I can see that it is here where the url is generated, but i don’t know:
1) why I can’t find my post when using ?video_category=id if for a normal category the same works. is it possible to have anything wrong on the definition of my category (custom), if so, what?
2)is it possible to change that value returns the slug instead of the id?
Thanks in advance
Teresa
- The topic ‘Link to custom category not working when using the id’ is closed to new replies.