Skip to content

Instantly share code, notes, and snippets.

@rwkyyy
Last active May 30, 2022 09:13
Show Gist options
  • Save rwkyyy/1e27d0d33b83ec1657df0c0c80e2d6cf to your computer and use it in GitHub Desktop.
Save rwkyyy/1e27d0d33b83ec1657df0c0c80e2d6cf to your computer and use it in GitHub Desktop.
DEAD simple breadcrumb PHP function with Polylang
//breadcrumbs
function get_breadcrumb() {
//default link (home
echo '<a href="' . home_url() . '" rel="nofollow">Home</a>';
//polylang conditional, you can remove this if you do not need
if (pll_current_language() == 'ro') {
echo '<a href="' . home_url() . '" rel="nofollow">Acasă</a>';
} else if (pll_current_language() == 'en') {
echo '<a href="' . home_url() . '" rel="nofollow">Home</a>';
} else if (pll_current_language() == 'hu') {
echo '<a href="' . home_url() . '" rel="nofollow">Itthon</a>';
}
//end of polylang
if ( is_category() || is_single() ) {
echo "&nbsp;&nbsp; &gt;&nbsp;&nbsp;";
the_category( ' &bull; ' );
if ( is_single() ) {
echo " &nbsp;&nbsp; &gt;&nbsp;&nbsp; ";
the_title();
}
} elseif ( is_page() ) {
echo "&nbsp;&nbsp; &gt;&nbsp;&nbsp;";
echo the_title();
} elseif ( is_search() ) {
echo "&nbsp;&nbsp; &gt;&nbsp;&nbsp;Search Results for... ";
echo '"<em>';
echo the_search_query();
echo '</em>"';
}
}
add_shortcode( 'deadsimple_breadcrumb', 'get_breadcrumb' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment