Content extraction

Content extraction is extremely simple with WPC, we have developing two primary functions :

With echo :

<?php the_wpcomponent('slug'); ?>

Without echo :

<?php $content = get_wpcomponent('slug'); ?>

We can combine several elements with the same slug, this is the order of creation which will take over. If two elements are reversed, the data will not follow, they will also be reversed.

Define structure and slugs

<?php
/*
Template Name: Simplicité
Description: WordPress Grid, double col, single title
---------------------------------------------------------------------
{"type": "editor", "name": "Content", "slug": "content"}
{"type": "editor", "name": "Code", "slug": "code"}
{"type": "editor", "name": "After Code", "slug": "content"}
{"type": "editor", "name": "After Content", "slug": "code"}
---------------------------------------------------------------------
*/
?>
<section class="component _simplicite">
	<div class="container">
		<div class="inner row">

			<article>

				<?php the_wpcomponent( 'content' ) ?>

			</article>

			<article>

				<?php the_wpcomponent( 'code' ) ?>

			</article>
		  
			<article>
				<h2>After code</h2>
				<?php the_wpcomponent( 'content' ) ?>

			</article>
		  
			<article>
				  <h2>After Content</h2>
				  <?php the_wpcomponent( 'code' ) ?>

			</article>
		  
		</div>
	</div>
</section>