wordpress面包屑-主页>;博客>;邮递
我将非常感谢任何关于我面包屑的建议。头痛了两天,我就是想不出来 我有一个博客条目的静态页面,我想在面包屑中包含url mysite.com>博客>帖子 现在我有“mysite.com>post” 最坏的情况是删除主页url并更改为博客url,因此此面包屑至少显示博客url 博客>帖子wordpress面包屑-主页>;博客>;邮递,wordpress,breadcrumbs,Wordpress,Breadcrumbs,我将非常感谢任何关于我面包屑的建议。头痛了两天,我就是想不出来 我有一个博客条目的静态页面,我想在面包屑中包含url mysite.com>博客>帖子 现在我有“mysite.com>post” 最坏的情况是删除主页url并更改为博客url,因此此面包屑至少显示博客url 博客>帖子 function my_breadcrumb() { $sep = ' > '; if (!is_front_page()) { // Start the breadcrumb wi
function my_breadcrumb() {
$sep = ' > ';
if (!is_front_page()) {
// Start the breadcrumb with a link to your homepage
echo '<div class="breadcrumbs">';
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() ){
echo '<a href="'.get_site_url().'/blog">Blog</a>';
} 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 '</div>';
}
}
下面的代码工作得很好,但它不显示“blog url”,因为它只调用“home”,但我想包含一个echo或其他东西来显示静态页面blog after home(home-blog-post)
是否可以包含指向诸如echo“Blog”等页面的链接?或者甚至删除主页并将其放在面包屑之前,作为我的网站My blog>>然后是面包屑的其余部分(帖子/类别)
我的目标。。。
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>';
}
函数my_breadcrumb(){
$sep='rsaquo;';
如果(!是首页()){
//用指向主页的链接启动面包屑
回声';
回音'。$sep;
//检查当前页面是类别、存档还是单个页面。如果是,请显示类别或存档名称。
if(is_category()| | is_single()){
_类(“title_li=”);
}elseif(is_archive()| | is_single()){
如果(是_day()){
printf(uuu('%s',text_domain'),获取日期();
}elseif(is_month()){
printf(uuu('%s','text_domain'),获取_日期(x('fy','monthly archives date format','text_domain'));
}elseif(是年(){
printf(uuu('%s','text_domain'),获取_日期(x('Y','year archives date format','text_domain'));
}否则{
_e(‘博客档案’、‘文本域’);
}
}
//如果当前页面是一篇文章,请使用分隔符显示其标题
if(is_single()){
echo$sep;
_title();
}
//如果当前页面是静态页面,则显示其标题。
如果(是页面()){
附和标题();
}
//如果你有一个静态页面被分配给你的帖子列表页面。它会找到静态页面的标题并显示出来。例如主页>>博客
if(is_home()){
全球$员额;
$page_for_posts_id=get_选项(“page_for_posts”);
如果($page_for_posts_id){
$post=get_page($page_表示_posts\u id);
设置_postdata($post);
_title();
倒带帖子();
}
}
回声';
}
}
//
- 注意。我很好奇为什么贴子页面没有显示为代码所说的主页>>博客。(我创建了一个名为blog的页面,然后创建了settings-reading-posts页面,并使用home.php作为模板)。(首页使用名为welcome的页面,然后是settings-reading-FrontPage,模板是Front-page.php)。
**我正在制作我自己的主题,我不想添加更多的插件李>
function my_breadcrumb() {
$sep = ' > ';
if (!is_front_page()) {
// Start the breadcrumb with a link to your homepage
echo '<div class="breadcrumbs">';
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() ){
echo '<a href="'.get_site_url().'/blog">Blog</a>';
} 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 '</div>';
}
}
函数my_breadcrumb(){
$sep='>';
如果(!是首页()){
//用指向主页的链接启动面包屑
回声';
回音'。$sep;
//检查当前页面是类别、存档还是单个页面。如果是,请显示类别或存档名称。
if(is_category()| | is_single()){
回声';
}elseif(is_archive()| | is_single()){
如果(是_day()){
printf(uuu('%s',text_domain'),获取日期();
}elseif(is_month()){
printf(uuu('%s','text_domain'),获取_日期(x('fy','monthly archives date format','text_domain'));
}elseif(是年(){
printf(uuu('%s','text_domain'),获取_日期(x('Y','year archives date format','text_domain'));
}否则{
_e(‘博客档案’、‘文本域’);
}
}
//如果当前页面是一篇文章,请使用分隔符显示其标题
if(is_single()){
echo$sep;
_title();
}
//如果当前页面是静态页面,则显示其标题。
如果(是页面()){
附和标题();
}
//如果你有一个静态页面被分配给你的帖子列表页面。它会找到静态页面的标题并显示出来。例如主页>>博客
if(is_home()){
全球$员额;
$page_for_posts_id=get_选项(“page_for_posts”);
如果($page_for_posts_id){
$post=get_page($page_表示_posts\u id);
设置_postdata($post);
_title();
倒带帖子();
}
}
回声';
}
}
希望这对您有用。请查看我的答案。PPL,谢谢您的建议。它很管用,谢谢@JPDesign:如果我的答案对你有效,你应该接受并投票表决。