説明
- Replace term archive pages with custom Taxonomy Pages (CPT).
- Use the block editor to design archive landing pages.
- Includes a Taxonomy Archive Block to display posts.
- Fully customizable via templates and filter hooks.
仕組み
The Taxonomy Page will override the first page of a term archive. In Settings you can choose which taxonomies should have the option to create a Taxonomy Page.
For example, to create a Taxonomy Page for the News category:
- In Settings Reading select
Category. - Go to Posts Categories, hover over “News” and click Taxonomy Page.
- ブロックエディターでタクソノミーページを編集し、公開してください。
- View the page at
/category/news(assuming your permalink structure is set to “Post name”).
Taxonomy Archive Block
When editing a Taxonomy Page in the block editor, you also have access to the Taxonomy Archive Block. This block displays an overview of every post in the term archive. A number of options allow you to alter its behavior:
-
Number of Posts
Sets the maximum number of posts displayed in the overview. -
Toggle Button Text
Sets the text for the toggle button. This button appears when the total number of posts exceeds the number set in “Number of Posts”. -
Archive Button Text
Sets the text for the archive button. This button links to the second page of the term archive. It will be displayed when the amount of posts exceedsBlog pages show at mostin Settings Reading.
テンプレート構造
You can choose a template for the Taxonomy Page in the block editor. Alternatively, you can create your own template, by adding singular-taxonomy-page.php to your theme’s templates, or using the filter hook rich_taxonomy_include_template.
The default template hierarchy, from highest to lowest priority, is as follows:
singular-taxonomy-page.phppage.phpsingular.phpsingle.phpindex.php
カスタマイズ
Template Override: Taxonomy Archive Block
To override the layout of the Taxonomy Archive Block, copy these files into your theme under:
template-parts/rich-taxonomy/
Files:
archive-block-loop.php– Loop of post listarchive-block-more.php– Archive buttonarchive-block-toggle.php– Toggle button-
archive-block-wrapper.php– Wrapper of archiveStyles and Scripts
You can override the plugin’s styles and scripts using these hooks:
rich_taxonomy_block_asset_stylerich_taxonomy_block_asset_editor_stylerich_taxonomy_block_asset_scriptrich_taxonomy_block_asset_editor_script
見た目やスタイルを変更するには、 rich_taxonomy_block_asset_style を起点にすると良いでしょう。
Example: Override Style
// 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/archive-block' === $block_name ) {
$handle = 'my-archive-block';
}
return $handle;
}, 10, 2 );
This style will load on both the front-end and block editor.
デフォルトコンテンツ
タクソノミーページのデフォルトコンテンツを定義するには、 rich_taxonomy_default_post_object フィルターフックを使用してください。
Example: Define Default Content
/**
* 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, $context ) {
// 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 );インストール
プラグインディレクトリから
- Install and activate the plugin.
- Go to Settings Reading and select the taxonomies to enable.
GitHub から
Download from the Releases page.
FAQ
-
サポートはどこで受けられますか ?
-
サポートフォーラムで新しいチケットを作成してください。
-
どのように貢献できますか?
-
新しいIssueを作成するか、Pull Requestを送ってください。
評価
このプラグインにはレビューがありません。
貢献者と開発者
Rich Taxonomy はオープンソースソフトウェアです。以下の人々がこのプラグインに貢献しています。
貢献者変更履歴
1.1.7
- Enhancement for instructions.
- Bugfix: remove warning on non-taxonomy pages.
1.1.2
- テンプレートセレクターのバグを修正しました
1.1.1
- ブロックウィジェット画面が壊れるバグを修正しました。
- インストール手順を明確にするため、READMEを更新しました(props @megane9988)。
1.1.0
- ブロックが消える不具合を修正しました。
1.0.9
- タクソノミーページのエディター内にあるテンプレートセレクターの不具合を修正しました。
1.0.0
- 初回リリース。