admin管理员组文章数量:1026156
I have an issue with breadcrumbs working with bbpress forums on my website. I have tried a few different ways to overcome this & I think a simple solution would be something which states if the post type = forum then the breadcrumbs for that page should be Home > forum.
I have tried to integrate this within my breadcrumb functions php snippet with no joy, can anyone give me a pointer of what im doing wrong?
<?php
function the_breadcrumb() {
global $post;
$post_type = $post->post_type;
echo '<ul id="breadcrumbs">';
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li class="separator"> / </li><li> ');
if (is_single()) {
echo '</li><li class="separator"> / </li><li>';
the_title();
echo '</li>';
}
} elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output;
}
echo $output;
echo '<span title="'.$title.'"> '.$title.'</span>';
} else {
echo '<li><span> '.get_the_title().'</span></li>';
}
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
elseif (is_post_type('forum') && is_post_type('post') && is_post_type('topic') && is_post_type('reply')){
echo"<li>FORUM BREADCRUMBS"; echo'</li>';
}
echo '</ul>';
}
?>
Thank you
I have an issue with breadcrumbs working with bbpress forums on my website. I have tried a few different ways to overcome this & I think a simple solution would be something which states if the post type = forum then the breadcrumbs for that page should be Home > forum.
I have tried to integrate this within my breadcrumb functions php snippet with no joy, can anyone give me a pointer of what im doing wrong?
<?php
function the_breadcrumb() {
global $post;
$post_type = $post->post_type;
echo '<ul id="breadcrumbs">';
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li class="separator"> / </li><li> ');
if (is_single()) {
echo '</li><li class="separator"> / </li><li>';
the_title();
echo '</li>';
}
} elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output;
}
echo $output;
echo '<span title="'.$title.'"> '.$title.'</span>';
} else {
echo '<li><span> '.get_the_title().'</span></li>';
}
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
elseif (is_post_type('forum') && is_post_type('post') && is_post_type('topic') && is_post_type('reply')){
echo"<li>FORUM BREADCRUMBS"; echo'</li>';
}
echo '</ul>';
}
?>
Thank you
Share Improve this question asked Sep 3, 2014 at 8:34 user35960user35960 2- I'm not sure what you want, but shouldn't you use an OR instead of AND in the is_post_type evaluation? – Tomás Cot Commented Sep 3, 2014 at 12:13
- oh yeah i completley missed that. My bad – user35960 Commented Sep 3, 2014 at 13:07
1 Answer
Reset to default 0I managed to fix this by:
<?php
function the_breadcrumb() {
global $post;
$post_type = $post->post_type;
echo '<ul id="breadcrumbs">';
if(get_post_type() == 'forum' OR get_post_type() == 'topic' OR get_post_type() == 'reply') {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
echo '<a href="https://link">Forum</a>';
echo ' / ';
echo the_title();
}
elseif (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li class="separator"> / </li><li> ');
if (is_single()) {
echo '</li><li class="separator"> / </li><li>';
the_title();
echo '</li>';
}
}
elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output;
}
echo $output;
echo '<span title="'.$title.'"> '.$title.'</span>';
} else {
echo '<li><span> '.get_the_title().'</span></li>';
}
}
}
}
?>
I have an issue with breadcrumbs working with bbpress forums on my website. I have tried a few different ways to overcome this & I think a simple solution would be something which states if the post type = forum then the breadcrumbs for that page should be Home > forum.
I have tried to integrate this within my breadcrumb functions php snippet with no joy, can anyone give me a pointer of what im doing wrong?
<?php
function the_breadcrumb() {
global $post;
$post_type = $post->post_type;
echo '<ul id="breadcrumbs">';
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li class="separator"> / </li><li> ');
if (is_single()) {
echo '</li><li class="separator"> / </li><li>';
the_title();
echo '</li>';
}
} elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output;
}
echo $output;
echo '<span title="'.$title.'"> '.$title.'</span>';
} else {
echo '<li><span> '.get_the_title().'</span></li>';
}
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
elseif (is_post_type('forum') && is_post_type('post') && is_post_type('topic') && is_post_type('reply')){
echo"<li>FORUM BREADCRUMBS"; echo'</li>';
}
echo '</ul>';
}
?>
Thank you
I have an issue with breadcrumbs working with bbpress forums on my website. I have tried a few different ways to overcome this & I think a simple solution would be something which states if the post type = forum then the breadcrumbs for that page should be Home > forum.
I have tried to integrate this within my breadcrumb functions php snippet with no joy, can anyone give me a pointer of what im doing wrong?
<?php
function the_breadcrumb() {
global $post;
$post_type = $post->post_type;
echo '<ul id="breadcrumbs">';
if (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li class="separator"> / </li><li> ');
if (is_single()) {
echo '</li><li class="separator"> / </li><li>';
the_title();
echo '</li>';
}
} elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output;
}
echo $output;
echo '<span title="'.$title.'"> '.$title.'</span>';
} else {
echo '<li><span> '.get_the_title().'</span></li>';
}
}
}
elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
elseif (is_post_type('forum') && is_post_type('post') && is_post_type('topic') && is_post_type('reply')){
echo"<li>FORUM BREADCRUMBS"; echo'</li>';
}
echo '</ul>';
}
?>
Thank you
Share Improve this question asked Sep 3, 2014 at 8:34 user35960user35960 2- I'm not sure what you want, but shouldn't you use an OR instead of AND in the is_post_type evaluation? – Tomás Cot Commented Sep 3, 2014 at 12:13
- oh yeah i completley missed that. My bad – user35960 Commented Sep 3, 2014 at 13:07
1 Answer
Reset to default 0I managed to fix this by:
<?php
function the_breadcrumb() {
global $post;
$post_type = $post->post_type;
echo '<ul id="breadcrumbs">';
if(get_post_type() == 'forum' OR get_post_type() == 'topic' OR get_post_type() == 'reply') {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
echo '<a href="https://link">Forum</a>';
echo ' / ';
echo the_title();
}
elseif (!is_home()) {
echo '<li><a href="';
echo get_option('home');
echo '">';
echo '<i class="ts-awesome-home" style="font-size:14px;letter-spacing: 2px;"></i> Home';
echo '</a></li><li class="separator"> / </li>';
if (is_category() || is_single()) {
echo '<li>';
the_category(' </li><li class="separator"> / </li><li> ');
if (is_single()) {
echo '</li><li class="separator"> / </li><li>';
the_title();
echo '</li>';
}
}
elseif (is_page()) {
if($post->post_parent){
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
foreach ( $anc as $ancestor ) {
$output = '<li><a href="'.get_permalink($ancestor).'" title="'.get_the_title($ancestor).'">'.get_the_title($ancestor).'</a></li> <li class="separator">/</li>'.$output;
}
echo $output;
echo '<span title="'.$title.'"> '.$title.'</span>';
} else {
echo '<li><span> '.get_the_title().'</span></li>';
}
}
}
}
?>
本文标签: bbpressIf post typeforum then breadcrumbs Home gt Forums
版权声明:本文标题:bbpress - If post type = forum then breadcrumbs Home > Forums 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745624837a2159799.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论