The component
A component is a PHP file containing two necessary elements.
Data structure
The first is data structure from JSON containing a simple definition of the fields to add.
<?php
/*
Template Name: Code
Description: WordPress Grid, double col, single title
---------------------------------------------------------------------
{"type": "editor", "name": "Content", "slug": "content"}
---------------------------------------------------------------------
*/
?>
This JSON will define which fields will be added to the administration of content. Each addition of a component, the fields will be automatically added. You can add as many components as necessary, there is no limit.
HTML rendering
The component also includes its own rendering. Cool interest to WPComponent, structure and HTML are under the eyes simultaneously.
JSON defined eg content “my_content”. In the HTML the_wpcomponent(‘my_content’) will return the recorded data.
<section class="component _code -content">
<div class="inner">
<?php the_wpcomponent( 'content' ) ?>
</div>
</section>
<?php
/*
Template Name: Code
Description: WordPress Grid, double col, single title
---------------------------------------------------------------------
{"type": "editor", "name": "Content", "slug": "content"}
---------------------------------------------------------------------
*/
?>
<section class="component _code -content">
<div class="inner">
<?php the_wpcomponent( 'content' ) ?>
</div>
</section>