我会非常感谢有关我的面包屑的任何建议 . 2天的头痛,我只是想不通 .
我有一个博客条目的静态页面,我想在面包屑中包含url .
mysite.com>博客>发布
现在我有“mysite.com>帖子”
最糟糕的情况是删除主网址并更改博客网址,因此这个痕迹显示至少是博客网址 .
博客>发布
以下代码工作得很好,但它不显示“博客网址”,因为它只调用“home”,但我想要包含一个echo或者某些内容来显示名为blog的静态页面(home - blog - post) .
是否可以包含指向页面的链接,例如echo'Blog </ a>'?或者甚至在面包屑之前删除主页和地点<a href = />我的网站</ a> >> <a href = / blog>我的博客</ a> >>然后其余的痕迹(帖子/类别) .
我的目标...... mysite.com>博客>帖子
谢谢 !
function my_breadcrumb() {
$sep = ' › ';
if (!is_front_page()) {
// Start the breadcrumb with a link to your homepage
echo '<div class="x"><nav class="x">';
echo '<a href="';
echo get_option('home');
echo '">';
bloginfo('name');
echo '</a>' . $sep;
// Check if the current page is a category, an archive or a single page. If so show the category or archive name.
if (is_category() || is_single() ){
the_category('title_li=');
} elseif (is_archive() || is_single()){
if ( is_day() ) {
printf( __( '%s', 'text_domain' ), get_the_date() );
} elseif ( is_month() ) {
printf( __( '%s', 'text_domain' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'text_domain' ) ) );
} elseif ( is_year() ) {
printf( __( '%s', 'text_domain' ), get_the_date( _x( 'Y', 'yearly archives date format', 'text_domain' ) ) );
} else {
_e( 'Blog Archives', 'text_domain' );
}
}
// If the current page is a single post, show its title with the separator
if (is_single()) {
echo $sep;
the_title();
}
// If the current page is a static page, show its title.
if (is_page()) {
echo the_title();
}
// if you have a static page assigned to be you posts list page. It will find the title of the static page and display it. i.e Home >> Blog
if (is_home()){
global $post;
$page_for_posts_id = get_option('page_for_posts');
if ( $page_for_posts_id ) {
$post = get_page($page_for_posts_id);
setup_postdata($post);
the_title();
rewind_posts();
}
}
echo '</nav></div>';
}
}
//
- 注意 . 我很好奇为什么帖子页面不想添加更多插件 .
1 回答
显示预期网址的面包屑,例如:mysite.com> blog> post
希望这对你有用 .