Tags: taxonomy, terms, seo
Contributors: tarosky, Takahashi_Fumiki
Tested up to: 6.3
Requires at least: 5.9
Requires PHP: 7.0
Stable Tag: nightly
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
A WordPress plugin to enrich taxonomy archive.
This plugin create a custom post type "Taoxnomy Page" which related to a term.
Taxonomy Page will override the 1st page of term archive. You can choose which taxonomy to have a Taxonomy Page.
For example:
- You have decided "category" to have Taxonomy Page.
- Create a Taxonomy Page "Book" for category "Book".
- Edit the Taxonomy Page in block editor and publish it.
- Now the 1st page of "Book" category
<code>/category/book</code>
will dipslay the contents of the Taxonomy Page "Book".
You can choose a template for the taxonomy page in editor,
but you can put singular-taxonomy-page.php
template in your theme and there's no need to choose.
Below is the default template priority.
- singular-taxonomy-page.php
- page.php
- singular.php
- single.php
- index.php
Filter hook rich_taxonomy_include_template
is also available.
Archive blocks has tempalte structure like below.
template-parts
- rich-taxonomy
- archive-block-loop.php // Loop of post list.
- archive-block-more.php // Link button.
- archive-block-toggle.php // Toggle button.
- archive-block-wrapper.php // Wrapper of archive.
If the theme has files in the same path, that priors. Copy the file and customize one as you like.
To override styles, 4 hooks are available.
rich_taxonomy_block_asset_style
rich_taxonomy_block_asset_editor_style
rich_taxonomy_block_asset_script
rich_taxonomy_block_asset_editor_script
To change looks & feels, rich_taxonomy_block_asset_style
is the best starting point.
// Register style.
add_action( 'init', function() {
wp_registeR_style( 'my-archive-block', $url, $deps, $version );
} );
// Override handle.
add_filter( 'rich_taxonomy_block_asset_style', function( $handle, $block_name ) {
if ( 'rich-taxonomy/arcvhie-block' === $block_name ) {
$handle = 'my-archive-block';
}
return $handle;
}, 10, 2 );
This style is loaded in both public and editor.
To define the default contents of the taxonomy page, use rich_taxonomy_default_post_object
filter hook.
/**
* Filter default post object.
*
* @param array $args Post object passed to wp_insert_post().
* @param WP_Term $term Term object assigned to this post.
* @param string $context Currently only 'api' is supported.
*/
add_filter( 'rich_taxonomy_default_post_object', function( $args, $term, $contest ) {
// If specific taxonomy, enter default content.
if ( 'category' === $term->taxonomy ) {
// Post body.
$args['post_content'] = 'Here comes default content.';
// Publish immediately.
$args['post_status'] = 'publish';
}
return $args;
}, 10, 3 );
- Click install and activate it.
- Select the taxsonomies at the Reading Settings page (Setting > Reading).
See releases.
Please create a new ticket on the support forum.
Create a new issue or send pull requests.
- Fix bug on template selector.
- Fix a bug that breaks the block widgets screen.
- Update README for clearance of installation. props @megane9988
- Fix the bug for block disappearing.
- Fix a bug in the template selector in the taxonomy page editor.
- First release.