Hi!
When using the big grid, the category tags show up fine with any normal post. But some of my posts being in the chosen categories for the big grid are not normal posts but are of a custom post type. They show up just fine, but the category tag on them doesn’t.
The category in question is set up fine in the theme panel and shows up with normal posts. But not, if the post is a CTP.
In td_module.php on line 443, there is a split between built in post types and custom post types. I think the error is on that part handling the custom post types, because it tries to retrieve the queried object from wp_query on line 486 which produces the main page, not the query of the big grid.
If I change line 443 to
if (1==1 || array_key_exists($current_post_type, $builtin_post_types)) {
(which is neither elegant nor intelligent, but helps to track down the error 🙂 ) then the category tag on the big grid is displayed fine even on the custom post type posts.
Could you fix that? Or do I make a mistake here?
Regards,
Rolf
-
This topic was modified 9 years by
rk.
Hello Rolf,
There is no bug and no mistake done. The category tag simply was not built to show up on custom post types. The CPT usually has a custom taxonomy, not a standard ‘category’ That is why we did not add any tag on CPt’s. If your code works and does not cause any issues, then it;s a good solution. Our theme has limited support for custom post types unfortunately.
Thank you!
Hi,
The theme was designed and it works with default post types. For custom types you will need to make changes in the code and unfortunately the td_module.php file cannot be overwritten via child theme.
Thanks!
Hello,
It is not that simple I’m afraid. in wordpress each post relies on a taxonomy. A post has a category as a taxonomy. A custom post type cannot have the same taxonomy as the standard post and that why it is not simple as there are lots of custom taxonomies out there.
Thanks.
Well, o course a custom post type can have a standard post category. As you see in the above code, it just works 🙂 I add the categories and the post types in the block in Visual Composer and everything would work fine – if the theme wouldn’t lock out custom post types by default.
If it wouldn’t, your users could display any custom post type in the Big grid easily with its associated category. But it’s your choice, of course. 🙂 For me, it makes everything much harder because I have to come up with a complicated solution for beeing update safe – if it it working at all… In the end it has to be done via JavaScript – thats a little dirty 😉
By the way: I myself are not especially interested in having the category displayed. If the custom post type would be displayed instead, that would be fine. But it doesn’t… there is just no category-div.
If I examine the code, the following line fails:
if ( $current_queried_term instanceof WP_Term ) {
So my custom post type post seems not to be instanceof WP_Term – do you know, what the problem could be?
This is a wordpress class that is used to create the wp_term object: https://developer.wordpress.org/reference/classes/wp_term/
Thanks.