Last active
May 31, 2019 02:13
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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