Re-use bits of code in multiple locations but edit in one.
Create a folder called “template-parts” in your theme
Inside that folder, add a PHP file called “content-example.php”
To display this, use the following snippet
<?php get_template_part(‘template-parts/content’,’example’); ?>
If your file name does not contain a hypen, for example something like “team.php” – then the snippet changes to:
<?php get_template_part(‘template-parts/team’); ?>
Inside the file, add the following code:
<?php
/**
* The template part for displaying content example
*
*/
?>
<p>Content here</p>