Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dospuntocero/5662b32b0131643b922526ad39b351f4 to your computer and use it in GitHub Desktop.
Save dospuntocero/5662b32b0131643b922526ad39b351f4 to your computer and use it in GitHub Desktop.
How to create a Custom Post type template that uses a divi layout directly
## first in your functions.php add the following:
```
//Shortcode to show the module
function showmodule_shortcode($moduleid) {
extract( shortcode_atts( array('id' =>'*'), $moduleid ) );
return do_shortcode('[et_pb_section global_module="'.$id.'"][/et_pb_section]');
}
add_shortcode('showmodule', 'showmodule_shortcode');
```
## then create your single-customCPT.php file duplicating page.php from divi and look for line 45 :
```
the_content();
```
## and replace it for
```
echo do_shortcode('[showmodule id="YOUR LAYOUT ID"]');
```
### remember: you need to create your divi layout first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment