Rooms Developers (Custom Coding) Categories of CPT in blog module

Viewing 7 reply threads
    • #2488
      Mark Ateer
      Participant
        @mark
        Up
        0
        Down
        ::

        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?

        How to use Divi Blog Module for Custom Post Type

         

        [original FB post]

      • #2489
        Anita
        Participant
          @anita
          Up
          0
          Down
          ::

          Looking at that it only works if you add the categories to the core group, not a custom category for custom post type. I’ve been trying for awhile and contacted Divi about that a couple of times now and haven’t found a solution.

          • #2491
            Mark Ateer
            Participant
              @mark
              Up
              0
              Down
              ::

              @anita but step 2…says it clearly. What am I missing here? I commented on his post, we’ll see if he answers.

          • #2492
            Ann Chovey
            Participant
              @ann
              Up
              0
              Down
              ::

              Did you change the ‘you_cpt’ part of the PHP code to the slug of your CPT?

              I find a common error I encounter are commas and apostrophes not being code friendly (I don’t know how to properly word it). So I copy any code to a notepad before pasting it on any PHP files.

              • #2494
                Mark Ateer
                Participant
                  @mark
                  Up
                  0
                  Down
                  ::

                  @ann I did try that yes. I’m not sure if this still works though x it was September and I believe the Blog Module CPT update was October 17 with the theme builder.

                • #2495
                  Colin Sik
                  Participant
                    @colin
                    Up
                    0
                    Down
                    ::

                    @ann – Eventually it did work. Initially I didn’t catch where you just leave the post type as Post and select the Category. Once I added a fresh Blog module to the page (not edit the one I had already on the page), left the type as Post and selected the Category, it was all good. Thanks!

                • #2498
                  Dave Allipa
                  Participant
                    @dave
                    Up
                    0
                    Down
                    ::

                    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.

                    • #2500
                      Mark Ateer
                      Participant
                        @mark
                        Up
                        0
                        Down
                        ::

                        @mark I’d love to be able to use that handy toggle to use current category, so that I could put this in a theme builder template. But I’m guessing not.

                    • #2501
                      Ann Chovey
                      Participant
                        @ann
                        Up
                        0
                        Down
                        ::

                        I tried the tutorial as well and it worked.

                        Attachments:
                        • #2504
                          Ann Chovey
                          Participant
                            @ann
                            Up
                            0
                            Down
                            ::

                            @mark , did you check the Categories (WP Core) when you created your CPT? Also, make sure the slug is correct when you add it to the PHP bit.

                          • #2506
                            Mark Ateer
                            Participant
                              @mark
                              Up
                              0
                              Down
                              ::

                              @ann I will try this again, you guys give me hope!

                            • #2509
                              Colin Sik
                              Participant
                                @colin
                                Up
                                0
                                Down
                                ::

                                @ann – Spoke too soon. It doesn’t work. It was displaying all posts of the CPT. Not Posts with the Category. So no, it doesn’t work.

                                • #2511
                                  Ann Chovey
                                  Participant
                                    @ann
                                    Up
                                    0
                                    Down
                                    ::

                                    @colin can you give us a little more detail? What is your CPT slug? What is the slug of the CPT Category you want to show up on the Blog Module?

                                    • #2513
                                      Colin Sik
                                      Participant
                                        @colin
                                        Up
                                        0
                                        Down
                                        ::

                                        @ann – the CPT slug is casestudies
                                        and the category is appeals
                                        The slugs don’t have anything unusual like underscores, etc.
                                        The categories were set when adding the posts. Do they need to be added as CPT taxonomies in CPT UI? Would that be the issue?

                                      • #2515
                                        Ann Chovey
                                        Participant
                                          @ann
                                          Up
                                          0
                                          Down
                                          ::

                                          @colin I would suggest adding them as taxonomies.

                                        • #2517
                                          Colin Sik
                                          Participant
                                            @colin
                                            Up
                                            0
                                            Down
                                            ::

                                            @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.

                                          • #2518
                                            Colin Sik
                                            Participant
                                              @colin
                                              Up
                                              0
                                              Down
                                              ::

                                              @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?

                                            • #2521
                                              Colin Sik
                                              Participant
                                                @colin
                                                Up
                                                0
                                                Down
                                                ::

                                                @ann – Rather than trying to filter CPT by category, do you know if there is a way to filter/display CPT by Tag instead?

                                              • #2523
                                                Ann Chovey
                                                Participant
                                                  @ann
                                                  Up
                                                  0
                                                  Down
                                                  ::

                                                  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.

                                                • #2525
                                                  Colin Sik
                                                  Participant
                                                    @colin
                                                    Up
                                                    0
                                                    Down
                                                    ::

                                                    @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.

                                                  • #2526
                                                    Colin Sik
                                                    Participant
                                                      @colin
                                                      Up
                                                      0
                                                      Down
                                                      ::

                                                      @ann – Maybe this helps – when I initially add the Blog Module, I leave the Type as “Post” and when I select the category, it shows the “no content found” message. Once I change the Type to thr CPT I set up, the content shows up perfectly, by category – until I exit the Visual Builder.

                                                    • #2527
                                                      Colin Sik
                                                      Participant
                                                        @colin
                                                        Up
                                                        0
                                                        Down
                                                        ::

                                                        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.

                                                        Divi Filterable Blog Module

                                                         

                                                      • #2531
                                                        Ann Chovey
                                                        Participant
                                                          @ann
                                                          Up
                                                          0
                                                          Down
                                                          ::

                                                          Glad you found something that worked for your needs. 🙂

                                                  • #2533
                                                    Dee Zynah
                                                    Participant
                                                      @dee
                                                      Up
                                                      0
                                                      Down
                                                      ::

                                                      thanks a lot i have solved that problem

                                                    • #2535
                                                      Ann Chovey
                                                      Participant
                                                        @ann
                                                        Up
                                                        0
                                                        Down
                                                        ::

                                                         

                                                      • #3510
                                                        Michael Schmidt
                                                        Participant
                                                          @summerfresh
                                                          Up
                                                          0
                                                          Down
                                                          ::

                                                          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()),

                                                      Viewing 7 reply threads
                                                      • You must be logged in to reply to this topic.