Skip to main content

Components

Put a part used on several pages in templates/ and load it with get_template_part().

Name the file after the component class, without the c- prefix.

templates/contact-banner.php
-> .c-contact-banner
-> data/scss/object/component/_contact-banner.scss
// templates/contact-banner.php
<section class="c-contact-banner">
<!-- ... -->
</section>
// page-company.php
<?php get_template_part('templates/contact-banner'); ?>

Values can be passed with the third argument and read from $args in the part.

<?php get_template_part('templates/contact-banner', null, ['title' => 'お問い合わせ']); ?>

In the content​

To show a part inside the content entered on the admin screens, use the [include_template] shortcode. slug and name are passed to get_template_part().

[include_template slug="templates/contact-banner"]