Changing the Divi projects custom post type to anything you want

Now fixed for Divi 2.5

Clone this project on GitHub.

I’m currently building a website for a friend of Jane, using the Divi theme from Elegant Themes. The website is for a holiday property letting company. This post explains how I changed the built-in Projects content type to Properties, and how you can change it to anything you want.

The problem

Divi is a great theme to use: it’s very flexible, it’s responsive (so it works equally well on smartphones as well as huge desktop monitors), and it has the easiest, drag-and-drop editor that I’ve ever used for WordPress.

Divi comes with a built in content type called Projects; WordPress calls them ‘custom post types’. I use this content type on my own website to list the various projects that I’ve been involved in over the years.

As you can see from the WordPress admin menu ‘Projects’ appears on the list beneath Posts, Media, Pages, and Comments:

WordPress menu with Divi installed shows Projects
WordPress menu with Divi installed

Divi also ships with a number of attractive ways to display your projects using its Portfolio and Filtered Portfolio modules. You can even display these full-width or as a grid, such as this:

Demo of Divi's Filtered Portfolio module displayed as a grid.
Demo of Divi’s Filtered Portfolio module displayed as a grid.

These are exactly the features that I’d like to use on the property letting website:

  • Keep properties separate from pages and posts, using a custom post type.
  • Display all properties in a grid.
  • Allow users to filter properties based on the categories that are assigned to them.

So, I want all the features of Divi’s built-in Projects custom post type, but I don’t want them to be called Projects. I want them to be called Properties.

Use a child theme

First, I strongly recommend that you use a child theme when customising Divi (or indeed any other WordPress theme). A child theme inherits the functionality and styling of another theme, called the parent theme, and allows you to make local customisations to it which will not be overwritten when the theme updates.

Elegant Themes have a useful walkthrough on how to create a child theme, and why you should be using one.

The WordPress Codex also has useful information about child themes.

How to do it

This very useful post on the Elegant Tweaks blog: “Change Divi Projects URL-permalink” got me started, and about 95% of the way.

I copied the code, added it to the functions.php file in my child theme, and set about editing it.

remove_action / add_action

In a nutshell the code from Elegant Tweaks does two things:

  1. It defines a new function — called child_et_pb_register_posttypes() — that will redefine the characteristics of the Projects content type.
  2. It removes the default Projects custom post type contained in Divi, and replaces it with our one in the child theme.

This last point, I believe, is simply to be tidy: rather than clumsily overwriting the existing ‘project’ custom post type it gracefully removes the old one, and creates a redefined version in its place.

Labels

In that Elegant Themes post the author was only concerned with changing the URL from /projects/ to /photos/. So in his example, the names used in the WordPress admin screens still referred to projects: Edit Project, Add New Project, etc. But I want to change these too.

In the code for a custom post type these are referred to as ‘labels’ and are defined in the $labels array. This is what my code looks like now:

<?php function child_et_pb_register_posttypes() { $labels = array( 'add_new' => __( 'Add New', 'Divi' ),
    'add_new_item' => __( 'Add New Property', 'Divi' ),
    'all_items' => __( 'All Properties', 'Divi' ),
    'edit_item' => __( 'Edit Property', 'Divi' ),
    'menu_name' => __( 'Properties', 'Divi' ),
    'name' => __( 'Properties', 'Divi' ),
    'new_item' => __( 'New Property', 'Divi' ),
    'not_found' => __( 'Nothing found', 'Divi' ),
    'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
    'parent_item_colon' => '',
    'search_items' => __( 'Search Properties', 'Divi' ),
    'singular_name' => __( 'Property', 'Divi' ),
    'view_item' => __( 'View Property', 'Divi' ),
);

 

As you can see, something I find useful is to list the elements alphabetically. Personally, I find it easier to work this way; your mileage may vary.

Obviously, if you are customising this for your own requirements simply edit this to reflect your needs.

Custom post type options

Next, we define the arguments to be passed to the register_post_type function. These define not only how the custom post type is used but also how it is displayed in the WordPress admin menu: where it sits and what icon it uses.

Slug

The most important option here, for our purpose of customising it, is the 'slug' key. You must set its value (in single quotes) to whatever you need it to be. In my case 'slug' => 'property'. I’ve highlighted this in the snippet below.

Just make sure you don’t set the slug to the same name as an existing page.

Menu icon and position

One useful new addition to the code provided by Elegant Tweaks are the options to set the menu icon and where it sits on the menu.

As these are properties I decided to use the home dashicon.

House icon
dashicons-admin-home

I also decided to move it up a bit, from beneath Comments to immediately below Posts. WordPress uses numbers to specify where custom post types should sit, e.g.

  • 5 — below Posts (this is where I want it to appear)
  • 10 — below Media
  • 15 — below Links
  • 20 — below Pages
  • 25 — below Comments

A full list can be found in the WordPress Codex.

So, here is the code I now have; I’ve highlighed these new menu options plus the ‘slug’ (how it will appear in the URL):

$args = array(
    'can_export' => true,
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'labels' => $labels,
    'menu_icon' => 'dashicons-admin-home',
    'menu_position' => 5,
    'public' => true,
    'publicly_queryable' => true,
    'query_var' => true,
    'show_in_nav_menus' => true,
    'show_ui' => true,
    'rewrite' => apply_filters(
    'et_project_posttype_rewrite_args', array(
    'feeds' => true,
    'slug' => 'property',
    'with_front' => false,
)),
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
);

 

Register the post type

The next line now does the grunt work and registers this custom post type with WordPress.

register_post_type( 'project', apply_filters(
    'et_project_posttype_args', $args )
);

This tells WordPress to apply all of these options to the ‘project’ custom post type.

Because we are redefining this existing custom post type (by changing the URL, the menu labels, the menu icon and position) it means that everything else (the default project page layouts and portfolio modules) will work as expected without any further customization.

Categories and tags

The rest of the code I left untouched. This code defines the categories and tags to be used with the projects/properties custom post type.

How it looks now

Adding all the code (see below for the complete script) this is what my WordPress admin menu looks like:

Divi theme now with Properties instead of Projects
Divi theme now with Properties instead of Projects

That’s now working as I expect it. Job done.

Complete code

Here is the full code that I have in my child theme’s functions.php file:

<?php function child_et_pb_register_posttypes() { $labels = array( 'add_new' => __( 'Add New', 'Divi' ),
    'add_new_item' => __( 'Add New Property', 'Divi' ),
    'all_items' => __( 'All Properties', 'Divi' ),
    'edit_item' => __( 'Edit Property', 'Divi' ),
    'menu_name' => __( 'Properties', 'Divi' ),
    'name' => __( 'Properties', 'Divi' ),
    'new_item' => __( 'New Property', 'Divi' ),
    'not_found' => __( 'Nothing found', 'Divi' ),
    'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
    'parent_item_colon' => '',
    'search_items' => __( 'Search Properties', 'Divi' ),
    'singular_name' => __( 'Property', 'Divi' ),
    'view_item' => __( 'View Property', 'Divi' ),
);

$args = array(
    'can_export' => true,
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'labels' => $labels,
    'menu_icon' => 'dashicons-admin-home',
    'menu_position' => 5,
    'public' => true,
    'publicly_queryable' => true,
    'query_var' => true,
    'show_in_nav_menus' => true,
    'show_ui' => true,
    'rewrite' => apply_filters( 'et_project_posttype_rewrite_args', array(
    'feeds' => true,
    'slug' => 'property',
    'with_front' => false,
)),
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
);

register_post_type( 'project', apply_filters( 'et_project_posttype_args', $args ) );

$labels = array(
    'name' => _x( 'Categories', 'Property category name', 'Divi' ),
    'singular_name' => _x( 'Category', 'Property category singular name', 'Divi' ),
    'search_items' => __( 'Search Categories', 'Divi' ),
    'all_items' => __( 'All Categories', 'Divi' ),
    'parent_item' => __( 'Parent Category', 'Divi' ),
    'parent_item_colon' => __( 'Parent Category:', 'Divi' ),
    'edit_item' => __( 'Edit Category', 'Divi' ),
    'update_item' => __( 'Update Category', 'Divi' ),
    'add_new_item' => __( 'Add New Category', 'Divi' ),
    'new_item_name' => __( 'New Category Name', 'Divi' ),
    'menu_name' => __( 'Categories', 'Divi' ),
);

register_taxonomy( 'project_category', array( 'project' ), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
) );

$labels = array(
    'name' => _x( 'Tags', 'Property Tag name', 'Divi' ),
    'singular_name' => _x( 'Tag', 'Property tag singular name', 'Divi' ),
    'search_items' => __( 'Search Tags', 'Divi' ),
    'all_items' => __( 'All Tags', 'Divi' ),
    'parent_item' => __( 'Parent Tag', 'Divi' ),
    'parent_item_colon' => __( 'Parent Tag:', 'Divi' ),
    'edit_item' => __( 'Edit Tag', 'Divi' ),
    'update_item' => __( 'Update Tag', 'Divi' ),
    'add_new_item' => __( 'Add New Tag', 'Divi' ),
    'new_item_name' => __( 'New Tag Name', 'Divi' ),
    'menu_name' => __( 'Tags', 'Divi' ),
);

register_taxonomy( 'project_tag', array( 'project' ), array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
) );

$labels = array(
    'name' => _x( 'Layouts', 'Layout type general name', 'Divi' ),
    'singular_name' => _x( 'Layout', 'Layout type singular name', 'Divi' ),
    'add_new' => _x( 'Add New', 'Layout item', 'Divi' ),
    'add_new_item' => __( 'Add New Layout', 'Divi' ),
    'edit_item' => __( 'Edit Layout', 'Divi' ),
    'new_item' => __( 'New Layout', 'Divi' ),
    'all_items' => __( 'All Layouts', 'Divi' ),
    'view_item' => __( 'View Layout', 'Divi' ),
    'search_items' => __( 'Search Layouts', 'Divi' ),
    'not_found' => __( 'Nothing found', 'Divi' ),
    'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
    'parent_item_colon' => '',
);

$args = array(
    'labels' => $labels,
    'public' => false,
    'can_export' => true,
    'query_var' => false,
    'has_archive' => false,
    'capability_type' => 'post',
    'hierarchical' => false,
    'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
);

register_post_type( 'et_pb_layout', apply_filters( 'et_pb_layout_args', $args ) );
}

function remove_et_pb_actions() {
    remove_action( 'init', 'et_pb_register_posttypes', 15 );
}

add_action( 'init', 'remove_et_pb_actions');
add_action( 'init', 'child_et_pb_register_posttypes', 20 );
?>

 

Final thoughts

Like many things on my blog I’m primarily putting it here for my own reference, but if you find it useful — or would like to suggest improvements or additional features — please leave a comment below.

Clone this project on GitHub.

Update: Remember to reset your permalinks

Friday 20 March 2015

I meant to say this in the article above. Sometimes WordPress gets a bit muddled when you play around with custom post types.

The way to fix this is to go to Settings > Permalinks > Save Changes.

That’s enough to flush the permalinks and your custom post type should work. I had to do that a couple of times while figuring out how to do this.

Update 2: Plugin discovery

Monday 20 April 2015

A few days ago I discovered this plugin: Divi Page Building for Custom Content Types.

This plugin allows you to use the Divi builder for Posts, or indeed any custom post type.

Update 3: Fix for Divi 2.5

Saturday 26 September 2015

I’ve now (finally) updated the code to make it work fully in Divi 2.5.

In the end it was quite simple: the add_action(...) and remove_action(...) priorities were wrong in my code. These tell WordPress in which order actions should be executed.

In my previous code I was instructing WordPress to unload the default Divi project custom post type before it had even been defined.

The default priority value is 10; I’d set mine to 0 and 1, respectively.

A huge thank you to Craig Campbell for his excellent Chrome Logger extension and ChromePHP class — two tools that greatly helped me work out what was going on.

Published by

Gareth Saunders

I’m Gareth J M Saunders, 46 years old, 6′ 4″, father of 3 boys (including twins). Latterly, web architect and agile project manager at the University of St Andrews and warden at Agnes Blackadder Hall. Currently on sabbatical. I am a priest in the Scottish Episcopal Church, and I sing with the NYCGB alumni choir.

86 thoughts on “Changing the Divi projects custom post type to anything you want”

  1. As someone mentioned on the Divi users Facebook group, it would be nice to be able to add new custom post types, not just replace the existing Projects one, but still be able to use a portfolio-style module in the page content. Something to look into later, I think.

  2. hey man, awesome post! thanks a lot!

    just a question though:

    how do you change the slug for the categories and tags for projects?

    if i understood everything correct they now look like this after the changes you suggest on your post:

    http://website.com/project_category/category-name/

    i’d like to change the “project_category” slug when to go a category archive page! is that possible?

  3. Doh 🙁 now I got my Recipes (which I substituted Projects with) setup. Unfortunately they totally crashed my post type so I cannot use it for anything.

    Think you’ve got a good idea of what can have happened?

    This is the comment I made in the Divi Theme forum:

    Site URL: http://maxadinforbranning.se/recept/yog … ukt-och-no
    WordPress Version: 4.1.1
    Has Your Theme Been Modified: Yes

    Hi,

    I have changed the Divi “Project” post type to “Recept” (which means recipes in Swedish) according to this guide:
    http://bit.ly/1xjI1IZ

    Unfortunately my recipes pages aren’t working for some reason and I wish you could help me find out why! Would be sad to have that whole section totally destroyed on my site 🙁

    I currently have 2 recipes listed on this page. It seems I can still use the Portfolio module in the page builder to list my recipes. Here’s tha page:
    http://maxadinforbranning.se/recept/

    Clicking on either of those recipes (‘Recept1’ or ‘Yoghurt med frukt och nötter’) will lead to nowhere, even though they are supposed to work as previously Projects.

    What do I do?

    I’m sort of paniced out.

  4. Thanks very much Gareth for this post! Really helpful, thanks!!

    Just wondering if it was possible to create a 2nd custom post type where the Divi builder is also usable?

    Thanks very much in advance!

    Adrian

  5. What a great post, thanks so much!! I have a question: I’d really like my projects to be hierarchical so I can enable Yoast breadcrumbs and use a function I use called SubPagePeek, which can optionally display a list of all child pages from a parent page. So as I add new child pages, I don’t have to update the parent page.

    I would like to do this on the projects, so I used your code but changed a few things and it stopped working. I am doing something wrong but am not sure what!

    When I register the post type, I changed capability_type to page, hierarchical to true and added page-attributes to the supports. Now what happens is that WordPress can’t find the page. Any ideas? Thanks!

  6. I faced the same problem and I chose another solution that I will expose you.

    To change the post-type slug I used a filter divi in the following function :

    add_filter( ‘et_project_posttype_rewrite_args’, ‘change_project_slug’, 10, 2);
    function change_project_slug ($array) {
    $array[‘slug’] = ‘news’ ; // new slug
    return $array;
    }

    I then changed the back office texts with poedit.

    Regarding the taxonomy, I removed the slug ‘project_category ‘project_category’ to beautify the permalink with a very light plugin:
    Remove Taxonomy Base Slug
    exemple => http://www.domain.com/news/project_category/Economy/

  7. Very nice article,
    but if you want to redefine some parts of the project custom post type, you are not forced to redefine entire funcion.

    You can use the et_project_posttype_args filter, to manipulate the post type $args array.

    with the following for example, I just rewrite the post support, adding the author

    add_filter( 'et_project_posttype_args', 'add_author_on_divi_projects' );
    function add_author_on_divi_projects ($args) {
    $args['supports'] = array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields', 'author' );
    return $args;
    }

  8. Hello Gareth, awesome and useful article!
    For the simple website I am creating I would like to be able to use the full width portfolio option etc with images from my “posts”/blog and not only have the choice to do so with the “projects” ( or whatever else i could name this as per your tutorial…. ) .
    Is this possible? Any idea how etc??
    Thank you so much for your time!!!

      1. I just put your code into my Divi child theme and it worked brilliantly and did exactly what i wanted and even more – that i did not know i wanted!! You are very clever!
        Now I just need to figure out how to include this “custom post type” in my regular blog/posts page and/or perhaps have another page which is dedicated just to this post type so that I can have link in my main menu to make these posts accessible from other places and not only from the full width portfolio…
        Thanks again!

  9. You’re a star Gareth, this worked a treat. We have a holiday property directory website in Norfolk that we are about to rebuild using Divi and the word project just didn’t look right.

    Your code worked great in our child theme, just as you said it would.

    I always worry about making these kind of changes and wonder if they are future proof as WordPress often updates and then breaks things. Great to see no one had had any issues so far 🙂

    Thanks very much for this.

    Regards, Pete

  10. Hi Gareth,

    I’ve been using your code for the past few months, and it’s worked great! However, it seems to no longer work with the latest update to Divi. Do you have any idea why?

    Thanks,
    Josh

      1. Gareth,
        It was the 2.5 update yesterday, a further update was released today. Your code function broke yesterday after 2.5 update 🙂

        Regards, Pete

  11. Hi Gareth,

    As Josh said above, your fab code no longer works on the latest Divi update.

    Any thoughts would be great as I’d only recently dicovered your code 🙂

    Regards, Pete

  12. Update for you. Been working with Divi support and they came up with this fix:

    function movies_register_post_type() {

    register_post_type(
    ‘project’,
    array(
    ‘labels’ => array(
    ‘name’ => __(‘Property’),
    ‘singular_name’ => __(‘Properties’)
    ),
    ‘public’ => true,
    ‘has_archive’ => true,
    ‘rewrite’ => array(
    ‘slug’ => ‘property’
    )
    )
    );

    } // end example_register_post_type
    add_action(‘wp_loaded’, ‘movies_register_post_type’);

    It seems to work fine however a few things like the house icon isn’t there and the order in admin has remained unchanged.
    All in all it seems to work well so far.

    Thought it worth sharing 🙂

      1. Thanks Gareth,
        Divi support are there to help and the indeed helped 🙂

        Has to be said the house icon and other bits aren’t as you did however it did the basics.

        Be interesting to see if you refine it a little 🙂

        1. Thanks Pete. Yeah, I’m planning on taking a look at it as soon as I can — not least because I can’t upgrade a friend’s site until I do fix it. Been up to my eyes with work, church, family stuff… May be some space this week to look at it.

          1. Hi Gareth, Josh and Pete,

            I have used your code also on a site and I needed it back working again after the latest Divi update and I have found that the original function has been moved to a sub sub folder in Divi (includes/builder/functions.php)

            With a search on WordPress.org/support on how to override a function that has been placed in a subfolder I have found this thread: https://wordpress.org/support/topic/overriding-parent-theme-sub-files-with-a-child-theme-how
            If you scroll to Jonfold’s answer, that solution worked for me.

            I basically copied the adjusted function made following the original article by Gareth, thanks for that 😉 , and placed that in the functions.php in the same folder hierarchy as the parent Divi theme. In the functions.php in the root of my child theme I have made a reference to this file with “require_once( get_stylesheet_directory() . ‘/includes/builder/functions.php’ );”

            I did needed to reset the permalinks however to make the adjustments work again.

            I hope this helps anyone, but as always backup and test first before deploying on a live site.

            Kind Regards,

            Wim

      1. Josh, as far as I can tell it is just replacing the last line :

        add_action( ‘init’, ‘child_et_pb_register_posttypes’, 1 );

        with:

        add_action( ‘wp_loaded’, ‘child_et_pb_register_posttypes’);

        I am not certain (as I am having another issue). Give it a try.

        1. I’ve fixed it by replacing the priority values in the remove_action and add_action calls:

          remove_action( ‘init’, ‘et_pb_register_posttypes’, 15 );
          add_action( ‘init’, ‘child_et_pb_register_posttypes’, 20 );

          It turns out that the default WordPress priority is set to 10, so we obviously want to run these _after _ Divi has loaded the default project custom-post-type.

          I hope that helps. And sorry for the delay in getting back with a solution. I now have this up and running using a child theme and Divi 2.5.3.

      2. Hi Josh,

        Thats what I did. A couple of things, it won’t do all that Gareth’s code did however I needed the URL to be Property and the code Divi Support supplied does this.
        It renames the tab in Admin to Property however no reorder or nice little house icon as Gareth did.
        Wondering if Gareth will improve on the code so it does all as he did 🙂

        Pete

  13. Greetings,

    I have a custom post type called ‘Articles’ from zeen101.com. It already has been coded to function and work visibly on the site by the developer’s plugin. However, the Divi builder doesn’t work on the custom post type. I found from wpthemefaqs.com these lines of code:

    function myprefix_add_post_types($post_types) {
    foreach(get_post_types() as $pt) {
    if (!in_array($pt, $post_types) and post_type_supports($pt, ‘editor’)) {
    $post_types[] = $pt;
    }
    }
    return $post_types;
    }
    add_filter(‘et_builder_post_types’, ‘myprefix_add_post_types’);

    function myprefix_add_meta_boxes() {
    foreach(get_post_types() as $pt) {
    if (post_type_supports($pt, ‘editor’)) {
    add_meta_box(‘et_settings_meta_box’, __(‘Divi Custom Post Settings’, ‘Divi’), ‘et_single_settings_meta_box’, $pt, ‘side’, ‘high’);
    }
    }
    return $post_types;
    }
    add_action(‘add_meta_boxes’, ‘myprefix_add_meta_boxes’);

    Although it does produce the builder in the custom post type, it doesn’t allow the ‘Hide Post Title’ option and doesn’t seem to cause ‘Hide until Scroll’ option to work either. Is there something I’d need to add to cause that to appear and function?

  14. Hi,

    I’ve followed this and got everything to work (new type name shows up in admin area), except the “projects” index page is showing up blank, and individual projects show up a blank page as well. This is even on versions 2.4 of Divi.

    Anyone encountered this or know what I might be missing?

    Thanks

  15. Would you be able to update this tutorial to work with the Divi 2.5 release? When we updated to Divi 2.5, it stopped working and was working great up until that point. Thanks!

  16. Hey all! I worked on this for a few hours this afternoon and I’ve worked out what the issue is. It’s surprisingly simple:

    The add_action and remove_action priorities were set too low. By default these are set to 10, but in my code I’d set them to 0 and 1. So the child theme was trying to unload the default Divi project custom-post-type before the parent theme Divi had even loaded it.

    Changing these to 15 and 20, respectively, fixed it for me. I now have everything working as expected, including the custom icon on the WordPress admin screen.

  17. Hi,

    I’m using the Pods plugin (https://wordpress.org/plugins/pods/) to create custom post types. It allows you to add taxonomies, including built-in taxonomies, to custom post types. I can apply the Projects’ taxonomies to my custom post types, but when I change Projects to Exhibitions using your code, I can no longer apply those taxonomies to custom post types. The problem only occurs when using your code to change Projects to Exhibitions. Do you have any advice/recommendations?

    Thanks,
    Josh

  18. is it possible to not just change but add new custom posts types? In my case I would like to add a chapters type as well as flashcards, and game cards. Sorry if this was already covered and i just missed it and thanks again for your wealth of information

  19. You sir… oh you! THANK YOU !!! Literally saved me hours of work in a single google search ending up on your blog post (I love SEO sometimes!).

    BIG BIG thank you again for this, worked out of the blue with a simple “search and replace” in my text editor using your original code.

    YOU ROCK !

  20. Amazing tutorial Gareth. Assuming the current code has all the updates, etc. mentioned in the comments?

    Is there a way to also keep the projects CPT and add a new one easily based on above code in the post?

    Thanks in advance,
    Al

  21. THANK YOU so much for documenting this!

    I agree, YOU ROCK !

    I’d like to include the “Page Attributes” box so I can set parent/child relationships to the entries. I thought I could set the first and/or last Hierarchical => true, but that didn’t work. Is turning this on a simple thing to do?

    thanks!
    jules

  22. After updating to WP WordPress 4.4 and Divi 2.5.8 I’m not able to access the Divi Library. I get the error message “You are not allowed to edit posts ”

    When I removed this code bit from my child theme functions.php I was able to regain access to the Divi Library page.

    There is a post in the Divi support forum
    https://www.elegantthemes.com/forum/viewtopic.php?f=187&t=486465&hilit=You+are+not+allowed+to+edit+posts

    Is this something you can help with?
    Thanks in advance,
    jules

  23. is it possible to not just change but add new custom posts types? In my case I would like to add a BOOKS type as well as MOVIES.Actually i want two types of Project that both follow PORTFOLIO MODULE.

  24. I need to change the text of the post listing order i.e. “Popular”, “Latest,””Most rated” to equivalent Danish terms.

    I would love it if you could point me in the right directions as to where this is done?

  25. Well done. I have been spending the last few hours making some tweaks to your code to enable events… your code worked like a charm and I cannot tell you how much I appreciate your help!

    1. Hi Hayim,
      Is there any chance you could share your work? I’m trying to get the divi projects post type to work for events so would love to know what approach you took. I’m sure I’m making it more complicated than it needs to be.
      Thanks,
      Lisa

    1. Im trying to figure this out too. I already have a custom post type in place. Looking through the code to see how to just make the switch instead of registering a new post type.

      Maybe some smart coders here will know.

  26. Hi,

    This is a great post! I am just at the point where I got everything working. I use my custom post type with hierarchy so they behave like pages. Because of this I want to use a custom single.php. I could do it with CSS but with a custom-single.php it would be more elegant I think.

    Do you now how to achieve this?

  27. Hey Gareth, great post, thanks for sharing the solution you provide regarding Projects custom post type on the Divi theme.
    But I have a crazy question, actually two:
    1. Is it possible to change the ‘project_category’ and ‘project_tag’ to ‘loans_category’ and ‘loans_tag’ so it matches up to what I changed already?
    2. Can the permalink structure be modified so it strips out the ‘project_category’ and ‘project_tag’ and just is site.com/loans/tag-term/ or site.com/loans/category-term? or does it have to remain site.com/loans/project_category/category-term ?

    Thanks for all your helpful info!

    1. Thanks for the great tweak, Gareth! (Still working for me on WP 4.7, Divi 3.025.

      To change the project-category and project-tag slugs, I used this code:

      ‘rewrite’ => array(
      ‘slug’ => ‘your-own-new-slug’
      )

      by adding it to Gareth’s code like:

      register_taxonomy( ‘project_category’, array( ‘project’ ), array(
      ‘hierarchical’ => true,
      ‘labels’ => $labels,
      ‘show_ui’ => true,
      ‘show_admin_column’ => true,
      ‘query_var’ => true,
      ‘rewrite’ => array(
      ‘slug’ => ‘your-own-new-slug’
      )
      ) );

  28. Hi Gareth,
    thank you for sharing your code.
    I read this post after a hard day working on filterable portfolio.
    I’m a great fan of Divi, but only today I realize that the divi portfolio can filter projects only by categories and not by tags.
    What do You think about? Is there any possibility to change the original project_category filter in a project_tag filter?

    Thank You for your attention and congratulations for your blog.

    Filippo

  29. Gareth, thanks a lot for sharing all this details. Works like a charm. Just wonder, if it’s possible to use Divi projects custom post type with extra taxonomies. I can add/register another taxonomy but I can’t see them in the Divi portfolio module. If you have a lot of types of taxonomies you don’t want to have all of them in one metabox. I guess it’s not only my problem. All the best.

  30. Just wanted to add my thanks as well. Well-written post and very helpful code. Help me solve my issue in less than 5 minutes!

    Also—I lived in Scotland for a while about twenty years ago and I absolutely loved it. Not only did you help me solve a problem, I really enjoyed a bit of cultural nostalgia by reading of a few of your other posts.

    Thanks so much for your kindness and generosity in sharing what you know. God bless!

  31. Thanks for this! Any idea if it will work with the new Divi 3.0? I’ve had issues in the past with making changes to a Divi child theme only to have it break when the client updates the theme.

    How do you avoid this issue? Do you recommend preventing the ability to upgrade a theme?

    Thanks.

  32. There seems to be a comatability issue with Divi 3.0 whilst everything works ok, the only way i can get to see the Divi>Divi Library which i need to be able to create some library templates is to remove the

    add_action( ‘init’, ‘remove_et_pb_actions’);
    add_action( ‘init’, ‘child_et_pb_register_posttypes’, 20 );

    Otherwise i get a permissions access error.

    Any advise?

    Alex

  33. Great job, Gareth. Thanks a lot!
    I’m facing another problem and I hope, someone can help me with that:
    I use the divi post type “projects” from the divi theme (wothout any editing) but also several others that I created via toolset types. In general it is possible to set parent or child post types for any custom post type. But somehow I can’t manage to do that in the project post type. Meaning: I can’t edit a post and combine it with a project.
    Does anyone have a clue what the problem might be?
    Would be great to get some help.
    Carlos

  34. Hello, All

    One thing this article doesn’t address is how to use a custom template with the taxonomy? Currently, if you make the changes as suggested, Divi will still load the single-project.php file as the post template.

    Ideally it would be better if it loaded single-mynewposttype.php.

    It doesn’t!

  35. Thank you for this post. It was what I needed. I actually went about it a different way as my needs where not as great as yours with this CPT issue.

    An easier (and probably safer) way to do this is to use the already provided filter in Divi Builder’s core.php module for the et_pb_register_posttypes() function. To change Divi’s ‘project’ CPT to something else, there’s no need to call your custom function via and add_action trigger. Instead you can simply hook into the filter already provided in the register_post_type( ‘project’, apply_filters( ‘et_project_posttype_args’, $args ) ) line.

    You have to supply it with the same label and arguments as you have above, but it works fine.

    Of course hooking into the filter does not accomplish your stated second goal at the beginning of this post — to remove the default Projects CPT. So it might not be as “tidy”, as you state!

    IMO it is always a better practice, when available, to utilize available WP filter hooks that allow you to accomplish a goal than do a more forceful change via triggering WP actions.

    As of my comment date, this approach works with the most current versions of the Divi theme and Divi builder.

    Divi (theme) Version: 3.0.97
    Divi Builder Version: 2.0.59

    Using the filter hook to rename the various project CPT attributes does not rename the categories and tags taxonomies for Divi’s ‘project’ CPT. If you wish to do that, you still have to forcefully change it as currently ET has not made filter hooks available to change these project taxonomies.

    I’ve put in a feature request with Elegant Themes to, at a minimum, include new filters in a future version of Divi Builder that will allow both the ‘project_categories’ and ‘project_tags’ taxonomy creation functions to be hooked into, allowing for these taxonomy labels to be changed to whatever a developer wants.

    I also suggested an even more significant feature that would instead create a setting in the “Divi > Divi Theme Options > General” and “Divi > Divi Theme Options > Builder” tabs that would allow developers and users to set their own name for this Divi-created CPT. This would require a global variable that would be referenced throughout Divi’s code in all places that deal with the ‘project’ CPT. So with one simple input box, the change could be affected throughout the entire Divi-based system — CPT slug (name), taxonomies, and labels.

    We’ll see if either of these options get implemented in a future version.

  36. There’s a much, much easier way to do this.

    Install WP-Types and change the CPT there. You can even uninstall WP-Types once you’re done.

    Then just add this to your child theme’s functions.php, to allow you to style those types with Divi:

    function my_et_builder_post_types( $post_types ) {
        $post_types[] = ‘YOUR_CPT_HERE’;
        $post_types[] = ‘ANOTHER_CPT_HERE’;
        return $post_types;
    }
    add_filter( ‘et_builder_post_types’, ‘my_et_builder_post_types’ );

  37. Hi,

    I used your tutorial to change the cpt “project” to “animals”: I am then able to use the filterable portolio module, which is great. I can only report one tiny bug: when this piece of code is present within the functions file, I cannot access the Divi library anymore. I need to comment the whole code, edit the template within the Divi library , then uncomment and refresh permalinks. Does anyone experience this as well?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.