PMC Term Content
Term Content is a WordPress plugin designed to enhance a theme's SEO capabilities by associating Gutenberg post content with taxonomy terms.
Usage
The plugin operates by creating a hidden post type linked with a taxonomy. Users can assign one of these posts to a term within that taxonomy's Edit Term admin interface. If there is a post attached to a term, the post's content may be displayed above a content river on the term archive template.
Configuration
-
Configure
'pmc-term-content'in the theme's plugin loader and plugin manifest. -
In the theme, create plugin configuration file for
pmc-term-content. See Filters for more. -
Ensure that newly available post types, prefixed with
pmc_tc_, are configured for Gutenberg. As an example, if enabling Term Content for the taxonomypost_tag, you must enable block editor and configure block defaults for the post typepmc_tc_post_tag. -
Render content in theme. To display the attached post content on the term archive template, use the function
render_content():
if ( class_exists( PMC\Term_Content\Frontend::class, false ) ) {
\PMC\Term_Content\Frontend::get_instance()->render_content();
}Filters
The plugin offers two filters to allow you to customize its behavior.
pmc_term_content_enable_taxonomy_types
Used to define a list of taxonomy types to activate.
add_filter( 'pmc_term_content_enable_taxonomy_types', 'enable_taxonomy_types' );
function enable_taxonomy_types() : array {
return [ 'post_tag' ]; // you could also include 'category'
}pmc_term_content_set_render_template
Used to define the template displaying term content. If not provided, plugin defaults to a basic template.
add_filter( 'pmc_term_content_set_render_template', 'set_render_template' );
function set_render_template( $template ) : string {
$new_template = sprintf( 'term-content.php' );
return file_exists( $new_template ) ? $new_template : $template;
}