[WordPress] 外掛分享: Jinx-Breadcrumbs

首頁外掛目錄 › Jinx-Breadcrumbs
WordPress 外掛 Jinx-Breadcrumbs 的封面圖片
全新外掛
安裝啟用
尚無評分
1743 天前
最後更新
問題解決
WordPress 5.0+ PHP 7.1+ v0.2.11 上架:2020-11-29

內容簡介

這個外掛讓你可以渲染面包屑並用篩選器配置它們。

使用方法

使用函數 ‘jinx_breadcrumbs’ 將面包屑呈現在你想要的位置。您可以通過向函數傳遞數組來覆蓋默認參數。

<?php

if (function_exists('jinx_breadcrumbs')) :

jinx_breadcrumbs([
// default args
'home' => __('主頁', 'jinx-breadcrumbs'),
'search' => __('搜索:"%s"', 'jinx-breadcrumbs'),
'404' => __('錯誤404', 'jinx-breadcrumbs'),
'author' => __('作者:%s', 'jinx-breadcrumbs'),
'year' => 'Y',
'month' => 'F',
'day' => 'd',
'before' => '<nav aria-label="breadcrumb"><ol>',
'after' => '</ol></nav>',
'before_item' => '<li%s>',
'after_item' => '</li>',
]);

endif;

?>

您還可以使用過濾器 ‘jinx_breadcrumbs’ 來覆蓋它們。

<?php

add_filter('jinx_breadcrumbs', function($args) {

return array_merge($args, [
'home' => __('主頁', 'cca'),
'search' => __('您搜索的是 "%s"', 'cca'),
]);

});

?>

該外掛將自動嘗試通過自定義分類和文章類型的重寫 slug 查找正確的檔案存檔頁面。

如果您希望更改此行為,您可以使用一些過濾器來操作存檔頁面。

如果您返回NULL,則存檔頁面將被刪除。

<?php

// 通過PID、類型(“taxonomy”或“post_type”)和名稱(例如'video')過濾存檔頁面
add_filter('jinx_breadcrumbs_archive', function($pid, $type, $name) {

return $pid;

}, 10, 3);

// 通過PID和名稱(例如'video')過濾存檔頁面
// 類型是過濾器的一部分(例如“jinx_breadcrumbs_archive_taxonomy”)
add_filter('jinx_breadcrumbs_archive_{type}', function($pid, $name) {

return $pid;

}, 10, 2);

// 通過PID過濾存檔頁面
// 類型和名稱是過濾器的一部分(例如“jinx_breadcrumbs_archive_post_type_video”)
add_filter('jinx_breadcrumbs_archive_{type}_{name}', function($pid) {

return $pid;

}, 10, 1);

?>

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.2.11) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Jinx-Breadcrumbs」→ 直接安裝(推薦)

原文外掛簡介

The plugin allows you to render breadcrumbs and configurate them with filters.
Usage
Use the function ‘jinx_breadcrumbs’ to render the breadcrumbs where you want them to be. You may overwrite the default arguments by passing an array to the function.
__('Home', 'jinx-breadcrumbs'),
'search' => __('Search: "%s"', 'jinx-breadcrumbs'),
'404' => __('Error 404', 'jinx-breadcrumbs'),
'author' => __('Author: %s', 'jinx-breadcrumbs'),
'year' => 'Y',
'month' => 'F',
'day' => 'd',
'before' => '

',
'before_item' => '',
'after_item' => '

',
]);

endif;

?>

You may also use the filter ‘jinx_jinx_breadcrumbs’ to overwrite them.
__('Start', 'cca'),
'search' => __('Your searched for "%s"', 'cca'),
]);

});

?>

The plugin will automatically try to find the correct archive pages by using the rewrite slug of custom taxonomies and post types.
If you may want to change this behavior, you may use some filters to manipulate the archive page.
If you return NULL, the archive page will be removed.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon