Created
August 30, 2012 03:14
-
-
Save bondarolik/3521969 to your computer and use it in GitHub Desktop.
Custom breadcrumbs function for WordPress
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
function breadcrumbs() { | |
#### Пример: | |
#### <a href="#">Главная</a> » <a href="#">Название Категории</a> » Название записи | |
# Predefined variables | |
#global $wp, $post; | |
$link_EOS = '<a href="'; | |
$link_CON = '">'; | |
$link_EOF = '</a>'; | |
$sep = " » "; # important to put it between two spaces | |
$homelink = $link_EOS . get_bloginfo('url') . $link_CON . 'Главная' . $link_EOF; | |
# Category archive | |
if (is_category()) { | |
echo $homelink . $sep; single_cat_title(); | |
} | |
# Tag archive | |
elseif (is_tag()) { | |
echo $homelink . $sep; single_tag_title(); | |
} | |
# Daily archive | |
elseif (is_day()) { | |
echo $homelink . $sep . "Архивы за "; the_time('F jS, Y'); | |
} | |
# Monthly archive | |
elseif (is_month()) { | |
echo $homelink . $sep . "Архивы за "; the_time('F, Y'); | |
} | |
# Yearly archive | |
elseif (is_year()) { | |
echo $homelink . $sep . "Архивы за "; the_time('Y'); | |
} | |
# Author archive | |
elseif (is_author()) { | |
echo $homelink . $sep . "Архивы "; is_author(); | |
} | |
# Paged archive | |
elseif (is_paged()) { | |
echo $homelink . $sep . "Архивы блога"; | |
} | |
# Single post | |
elseif (is_single()) { | |
echo $homelink . $sep; | |
the_category('title_li='); | |
echo $sep; | |
the_title(); | |
} | |
# Single page | |
elseif (is_page()) { | |
echo $homelink . $sep; | |
if ( $post->post_parent != 0) { | |
echo $link_EOS . get_page_link($post->post_parent) . $link_CON . get_the_title($post->post_parent) . $link_EOF . $sep; | |
} | |
echo the_title(); | |
} else {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment