Skip to content

Instantly share code, notes, and snippets.

@rocket-martue
Last active December 26, 2020 08:38
Show Gist options
  • Save rocket-martue/2e384695806a8228841fcc33f47a5f3d to your computer and use it in GitHub Desktop.
Save rocket-martue/2e384695806a8228841fcc33f47a5f3d to your computer and use it in GitHub Desktop.
テーマのsectionディレクトリのファイルを呼び出すショートコード
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