Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Maxim Botsman, [14.03.21 16:47]
- <?php
- //Хлебные крошки
- add_filter( 'wpseo_breadcrumb_links', 'wpseo_breadcrumb_add_woo_shop_link' );
- function wpseo_breadcrumb_add_woo_shop_link( $links ) {
- global $post;
- global $wp;
- $current_url = home_url(add_query_arg(array(), $wp->request));
- if ( is_woocommerce() ) {
- $breadcrumb[] = array(
- 'url' => get_permalink( woocommerce_get_page_id( 'shop' ) ),
- 'text' => 'Услуги',
- );
- if ( strpos($current_url, "shop") !== false ) {
- array_pop( $links );
- }
- array_splice( $links, 1, -2, $breadcrumb );
- }
- return $links;
- }
- add_filter( 'wpseo_breadcrumb_links', 'yoast_seo_breadcrumb_append_link' );
- function yoast_seo_breadcrumb_append_link( $links ) {
- global $post;
- global $wp;
- if ( is_single ( 123456 ) ) {
- $breadcrumb[] = array(
- 'url' => site_url( '/blog/' ),
- 'text' => 'Блог',
- );
- array_splice( $links, 1, -2, $breadcrumb );
- }
- return $links;
- }
- add_filter('wpseo_breadcrumb_single_link' ,'add_single_link', 10 ,2);
- function add_single_link($link_output, $link ){
- global $wp;
- $output = array();
- $current_url = home_url(add_query_arg(array(), $wp->request));
- // a bits for debug
- // echo $link["url"] . " --- " . $current_url;
- // echo "<br />";
- if($link["url"] === $current_url . "/") {
- array_push($output, "<span class=\"current-page-breadcrumb\">".$link["text"]."</span>");
- } else {
- array_push($output, "<span><a href=". $link["url"] .">" . $link["text"] . "</a></span>");
- }
- $html_output = "";
- foreach ($output as $idx=>$crumb) {
- $html_output .= $crumb;
- }
- return $html_output;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement