Last active
December 26, 2020 08:38
-
-
Save rocket-martue/2e384695806a8228841fcc33f47a5f3d to your computer and use it in GitHub Desktop.
テーマのsectionディレクトリのファイルを呼び出すショートコード
This file contains 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
add_shortcode( 'section', function( $atts ) { | |
extract( shortcode_atts( | |
array( | |
'slug' => '', | |
), $atts ) ); | |
ob_start(); | |
get_template_part( 'section/'.$slug ); | |
$html = ob_get_contents(); | |
ob_end_clean(); | |
return $html; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment