Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wpseo_breadcrumb_single_link' ,'change_yoast_single_link', 10 ,2);
- $COUNT_OF_ITEM = 0;
- function change_yoast_single_link($link_output, $link ){
- global $wp;
- global $COUNT_OF_ITEM;
- // складываем сюда результат сформированного ОДНОГО линка
- $result = array();
- // определяем текущую страницу
- $curr_page = home_url(add_query_arg(array(), $wp->request));
- // проверяем, если текущая страница, то делаем крошку БЕЗ ссылки
- if($link["url"] === $curr_page . "/") {
- $COUNT_OF_ITEM = $COUNT_OF_ITEM + 1;
- $text = $link["text"];
- array_push($result, "<li itemprop=\"itemListElement\" itemscope itemtype=\"https://schema.org/ListItem\"><span itemprop=\"name\">{$text}</span><meta itemprop=\"position\" content=\"{$COUNT_OF_ITEM}\"></li>");
- } else {
- $COUNT_OF_ITEM = $COUNT_OF_ITEM + 1;
- $text = $link["text"];
- $url = $link["url"];
- array_push($result, "<li itemprop=\"itemListElement\" itemscope itemtype=\"https://schema.org/ListItem\"><a rel=\"nofollow\" itemprop=\"item\" title=\"{$text}\" href=\"{$url}\"><span itemprop=\"name\">{$text}</span><meta itemprop=\"position\" content=\"{$COUNT_OF_ITEM}\"></a></li>");
- }
- $html_output = "";
- foreach ($result as $idx=>$crumb) {
- $html_output .= $crumb;
- }
- return $html_output;
- }
- add_filter('wpseo_breadcrumb_output', 'change_breadcrumb_names1');
- function change_breadcrumb_names1($output) {
- $output = str_replace("<span>", "", $output);
- $output = str_replace("</span>", "", $output);
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment