Last active
May 30, 2022 09:13
-
-
Save rwkyyy/1e27d0d33b83ec1657df0c0c80e2d6cf to your computer and use it in GitHub Desktop.
DEAD simple breadcrumb PHP function with Polylang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 " > "; | |
the_category( ' • ' ); | |
if ( is_single() ) { | |
echo " > "; | |
the_title(); | |
} | |
} elseif ( is_page() ) { | |
echo " > "; | |
echo the_title(); | |
} elseif ( is_search() ) { | |
echo " > 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