目前正在使用“maisha”主题。创建自定义页面以显示所有页面的面包屑,但是,如果没有应用侧栏或在widgets部分中“打开”,面包屑就会消失。这种页面情况很少发生,但在不需要侧边栏的情况下,我希望有面包屑。有多个父母,每个人都有子女和孙子女。
代码:
<?php if ( is_active_sidebar( \'sidebar-5\' ) ) : ?>
<div class="hfeed site default-page">
<div class="content site-content">
<main class="main site-main" role="main">
<div class="single-themes-page clear news">
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">
<?php
if(function_exists(\'bcn_display\'))
{
bcn_display();
}
?>
</div>
<div class="two_third">
<div id="primary" class="content-area">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( \'content\', \'page\' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
// End the loop.
endwhile;
?>
</div>
</div>
<div class="one_third lastcolumn">
<div id="sidebar" class="sidebar">
<?php get_sidebar( \'additional-two\' ); ?>
</div><!-- .sidebar -->
</div>
</div>
</main><!-- .content-area -->
</div><!-- .site-content -->
</div><!-- .site -->
<?php else: ?>
<div class="hfeed site default-page">
<div class="content site-content">
<main class="main site-main" role="main">
<div class="single-themes-page clear news">
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">
<?php
if(function_exists(\'bcn_display\'))
{
bcn_display();
}
?>
</div>
<div id="primary" class="content-area">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( \'content\', \'page\' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
// End the loop.
endwhile;
?>
</div>
</div>
</main><!-- .content-area -->
</div><!-- .site-content -->
</div><!-- .site -->
<?php endif; ?>
在上述代码中,我已经应用了两次此代码:
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">
<?php
if(function_exists(\'bcn_display\'))
{
bcn_display();
}
?>
</div>
一次在if语句的开头,另一次在else语句中。但是,面包屑不会出现。我做得不对吗?是逻辑错误,还是我误解了代码?