How to use Divi Blog Module for Custom Post Type

Divi Blog Module is a module in Divi where you can place your blog content anywhere in your WordPress website and in any format. Currently, it does not supports custom post type.

There are plugins to make it possible to use Divi Blog Module for Custom Post Type (CPT). One I found is Divi Custom Post Types, a specialist blog module for your CPTs. It cost $27.75 for a single site. I haven’t tried the plugin.

This how-to guide is to use Divi Blog Module for CPT without using such plugin. I used Custom Post Type UI plugin for creating CPT. I created Testimonial CPT with Testimonial category.

  1. Create Custom Post Type and check Categories (WP Core).
    Custom Post Type Categories WP Core
  2. Create and set Categories for your Custom Post Types.
  3. Add the code below to your child theme’s functions.php. Make sure to change your_cpt.
    add_action( 'pre_get_posts', function ( $q ) {
      if (!is_admin() && $q->is_category()) {
        $q->set( 'post_type', ['post', 'your_cpt'] );
      }
    });
    

    The code above is to include CPT’s category to the main query involving post type categories.

  4. Add blog module as usual and include only the category for your CPT.
    Divi Blog Module for Custom Post Type
1 comment
  1. Vikash
    Vikash
    January 20, 2020 at 6:47 am

    genius…Thanks for sharing brother.

    Reply
Leave a Reply

Your email address will not be published. Required fields are marked *