› Rooms › Developers (Custom Coding) › Categories of CPT in blog module
- This topic has 26 replies, 7 voices, and was last updated 1 year ago by
Michael Schmidt.
-
-
30 December 2021 at 1:30 am #2488::
Has anyone figured out how to get CATEGORIES of custom post types in the Blog Module? This tutorial claims to have a workaround, but I can’t figure it out. Any ideas?
[original FB post]
-
30 December 2021 at 1:32 am #2489
-
30 December 2021 at 2:25 am #2491
-
-
30 December 2021 at 2:25 am #2492
-
30 December 2021 at 2:29 am #2498::
Ok, tried it on my test site and got it to work. The trick is not to select your custom post type (leave as post) in the blog module but just select the category you want to display from your custom post type. That function is changing the query to set the custom post type slug into the query for you.
However the problem that you will have is now you cannot select the categories of normal posts. You would need to add in additional functions to target a specific page and/or template.
-
30 December 2021 at 2:30 am #2500
-
-
30 December 2021 at 2:32 am #2501
-
30 December 2021 at 2:34 am #2504
-
30 December 2021 at 2:35 am #2506
-
30 December 2021 at 2:36 am #2507
-
-
30 December 2021 at 2:37 am #2509
-
30 December 2021 at 2:39 am #2511
-
30 December 2021 at 2:41 am #2513
-
30 December 2021 at 2:42 am #2515
-
30 December 2021 at 2:44 am #2517::
@ann – Did the first two this way and it looks like it may be working. I added the categories as taxonomies then added a fresh blog module to the page. First selected the category listed under Post but then changed the Type to my CPT and it looks to be working. I’ll let you know how it plays out. Thanks again.
-
30 December 2021 at 2:44 am #2518::
@ann – Well that didn’t work either. Strangely, when I add the Blog Module in the Visual Builder the way I explained above, it filters the content correctly – just displaying my CPT in the selected Category. But as soon as I save and exit the Visual Builder, the display reverts to showing all posts of my CPT, regardless of category or taxonomy.
I think the problem, or where I’m missing something, is when I add the Blog Module after having added my category as a taxonomy, I’m still only given a list of the original categories I assigned to the custom content when it was added to the site. So I’m not sure how I’m associating the post with the correct taxonomy – since there is more than one taxonomy term (hence the need to filter in the first place). Any thoughts?
-
30 December 2021 at 2:46 am #2521
-
30 December 2021 at 2:47 am #2523::
If it’s showing properly while your on visual builder and reverts back when you exit, perhaps it’s a caching issue. Have you tried clearing cache on your browser or using incognito instead when viewing the page? You may also want to temporarily disable css minification as well as static css file generation within the Divi Settings.
I would rather troubleshoot this rather than look for another way of doing it, since it is proven to work. There might just be something that is amiss.
-
30 December 2021 at 2:48 am #2525::
@ann – I tried disabling static CSS generation and dumped the site cache, but the same occurs. It displays exactly as I need it in the visual builder, but as soon as I exit the Visual Builder, the display adds in all of the other posts in addition to those in the Category I’m filtering for. Very bizarre.
-
30 December 2021 at 2:48 am #2526
-
30 December 2021 at 2:50 am #2527::
I ended up using the Divi Filterable Blog Module. The trick with is you need to turn off the new builder as well as toggle off “use the latest builder experience” in the Divi Settings. Once you do that, you can use the plugin to select categories to display for CPTs and the filter actually works. The CSS is a little rough, but between the module and just adding some CSS to the theme CSS file, it worked out. You can turn the new builder back on once you have made the filter selections. A little time consuming for me because the old builder is painfully slow on the site I was working on, but it worked.
-
30 December 2021 at 2:51 am #2531
-
-
-
-
30 December 2021 at 3:09 am #2533
-
30 December 2021 at 3:11 am #2535
-
18 May 2022 at 3:44 pm #3510::
If anyone is still trying to do this, I found a solution that worked for me on the Divi Support Forums here: https://www.elegantthemes.com/forum/viewtopic.php?f=190&t=901090&hilit=Custom+Post+Type+Categories+in+Blog+Module&p=4903214#p4903214
line 367 of /Divi/includes/builder/module/Blog.php should be
‘post_type’ => array_values(get_post_types()),
-
- You must be logged in to reply to this topic.