Last active
March 15, 2018 19:34
-
-
Save indikatordesign/433385b4ad7be667e3537f7e4d430fe6 to your computer and use it in GitHub Desktop.
[Divi Layout Shortcode]
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
<?php | |
// Add layouts to the Divi library and get the ID from the corresponding URL | |
// To get your results, you can add a shortcode to text fields as follows: [divi-layout id="7"] | |
add_shortcode( 'divi-layout', function( $atts ) | |
{ | |
$atts = shortcode_atts( [ 'id' => '', ], $atts ); | |
if ( ! $atts['id'] || ! $p = get_post( (int) $atts['id'] ) ) | |
return false; | |
return ( ET_BUILDER_LAYOUT_POST_TYPE == $p->post_type ) ? do_shortcode( $p->post_content ) : false; | |
}); // end add_shortcode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment