admin管理员组文章数量:1130349
I'm trying to construct a breadcrumb trail where some of the paths consist of parent/child custom post types.
For example:
else if ( is_singular( 'resort' ) ) {
global $post;
$post_data = get_post($post->post_parent);
$parent_title = $post_data->post_title;
$parent_slug = $post_data->post_name;
echo '<li><a href="/destinations/" title="' . __('Destinations', 'bookyourtravel') . '">' . __('Destinations', 'bookyourtravel') . '</a></li>';
echo '<li><a href="/destinations/' . $parent_slug . '/" title="' . $parent_title . ' Villas">' . $parent_title . '</li>';
}
Whilst this outputs exactly what I'm after, for example:
Destinations > $parent_title
When I try to get the current page's title for the last path in the breadcrumb simply with:
echo "<li>";
echo the_title();
echo "</li>";
It ends up duplicating the second destination > $parent_title path above...
I attach a screenshot of the source code to illustrate this problem.
It seems by the usage of the_title(), it seems to wrap any mention of the current page title (Playa Blanca) in a link which links back to the parent page (Lanzarote) which hopefully can be seen in the image.
Why can't the above just echo the current page title (the_title()) at the end of the breadcrumb trail properly?
I just want 'Playa Blanca' to be at the end of the breadcrumb trail not linked and not interfering with anything else on the page.
I'm trying to construct a breadcrumb trail where some of the paths consist of parent/child custom post types.
For example:
else if ( is_singular( 'resort' ) ) {
global $post;
$post_data = get_post($post->post_parent);
$parent_title = $post_data->post_title;
$parent_slug = $post_data->post_name;
echo '<li><a href="/destinations/" title="' . __('Destinations', 'bookyourtravel') . '">' . __('Destinations', 'bookyourtravel') . '</a></li>';
echo '<li><a href="/destinations/' . $parent_slug . '/" title="' . $parent_title . ' Villas">' . $parent_title . '</li>';
}
Whilst this outputs exactly what I'm after, for example:
Destinations > $parent_title
When I try to get the current page's title for the last path in the breadcrumb simply with:
echo "<li>";
echo the_title();
echo "</li>";
It ends up duplicating the second destination > $parent_title path above...
I attach a screenshot of the source code to illustrate this problem.
It seems by the usage of the_title(), it seems to wrap any mention of the current page title (Playa Blanca) in a link which links back to the parent page (Lanzarote) which hopefully can be seen in the image.
Why can't the above just echo the current page title (the_title()) at the end of the breadcrumb trail properly?
I just want 'Playa Blanca' to be at the end of the breadcrumb trail not linked and not interfering with anything else on the page.
本文标签: Using thetitle() and fetching the parent page39s title and slug to construct breadcrumbs
版权声明:本文标题:Using the_title() and fetching the parent page's title and slug to construct breadcrumbs 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749211007a2333359.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论