cuberis / wp-componify
Components, our flexible content system.
0.1.0
2019-03-18 19:33 UTC
Requires
- php: >=7
This package is not auto-updated.
Last update: 2025-04-13 08:27:46 UTC
README
Components, our flexible content system.
Installing
composer require cuberis/wp-componify
.
Setup & Examples
- Setup new template parts in
/templates/components/
to match against ACF Flexible Content layout slugs. - Instantiate new Componify class in your page template.
- Sit back and enjoy!
<?php while (have_posts()) : the_post(); ?> <article> <header> <h1 class="entry-title"><?php the_title(); ?></h1> </header> <div class="entry-content"> <?php $components = new Componify(); $components->render(); ?> </div> </article> <?php endwhile; ?>
Arguments
prefix
(default: null) – Retrieve a prefixed set of component fields.
Filters
cuberis_set_component_html_attributes
/** * Example for modifying component wrapper attributes. * * @param array $attrs * @param string $slug * @return $attrs */ function cuberis_filter_component_html_attributes($attrs, $slug) { // Add a class modifier to just the text component. if ($slug === 'text') { $attrs['class'] .= ' component--example-modifier'; } // Add a new attribute to all components. $attrs['data-id'] = uniqid(); return $attrs; } add_filter('cuberis_set_component_html_attributes', 'cuberis_filter_component_html_attributes', 10, 2);