删除rel=";nofollow";来自woocommerce';添加到购物车';按钮

删除rel=";nofollow";来自woocommerce';添加到购物车';按钮,woocommerce,Woocommerce,WooCommerce正在我的网站上的产品上添加rel=“nofollow”链接到“添加到购物车”按钮,我不知道如何删除它。 我试着按照答案去做,但没能成功 非常感谢您的帮助。您可以使用woocommerce\u loop\u add\u to\u cart\u args从woocommerce循环中的add to cart按钮取消设置rel属性 add_filter( 'woocommerce_loop_add_to_cart_args', 'remove_rel', 10, 2 ); fun

WooCommerce正在我的网站上的产品上添加rel=“nofollow”链接到“添加到购物车”按钮,我不知道如何删除它。 我试着按照答案去做,但没能成功


非常感谢您的帮助。

您可以使用
woocommerce\u loop\u add\u to\u cart\u args
从woocommerce循环中的add to cart按钮取消设置
rel
属性

add_filter( 'woocommerce_loop_add_to_cart_args', 'remove_rel', 10, 2 );
function remove_rel( $args, $product ) {
    unset( $args['attributes']['rel'] );

    return $args;
}

您可以使用
woocommerce\u loop\u add\u to\u cart\u args
从woocommerce循环中的add to cart按钮取消设置
rel
属性

add_filter( 'woocommerce_loop_add_to_cart_args', 'remove_rel', 10, 2 );
function remove_rel( $args, $product ) {
    unset( $args['attributes']['rel'] );

    return $args;
}

我使用这个代码。但没有找到如何在“aria标签”中插入产品标题

// Change rel “nofollow” to rel “dofollow” on Shop Page Product button
add_filter( 'woocommerce_loop_add_to_cart_link', 'add_to_cart_dofollow', 10, 2 );
function add_to_cart_dofollow($html, $product){
    if($product->product_type == 'simple') {
        $html = sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" aria-label="Добавить в корзину" data-product_sku="%s" class="%s" %s>%s</a>',
        esc_url( $product->add_to_cart_url() ),
        esc_attr( isset( $quantity ) ? $quantity : 1 ),
        esc_attr( $product->get_id() ),
        esc_attr( $product->get_sku() ),
        esc_attr( isset( $args['class'] ) ? $args['class'] : 'button product_type_variable add_to_cart_button' ),
        esc_attr( isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : ''),
        esc_html( $product->add_to_cart_text() )
    );
    }else {
    $html = sprintf( '<a href="%s" data-quantity="%s" data-product_id="%s" aria-label="Выбрать" data-product_sku="%s" class="%s" %s>%s</a>',
        esc_url( $product->add_to_cart_url() ),
        esc_attr( isset( $quantity ) ? $quantity : 1 ),
        esc_attr( $product->get_id() ),
        esc_attr( $product->get_sku() ),
        esc_attr( isset( $args['class'] ) ? $args['class'] : 'button product_type_variable add_to_cart_button' ),
        esc_attr( isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : ''),
        esc_html( $product->add_to_cart_text() )
    );
    }
    return $html;
}
//将商店页面产品按钮上的rel“nofollow”更改为rel“dofollow”
添加过滤器('woocommerce\u loop\u add\u to \u cart\u link'、'add\u to \u cart\u dofollow',10,2);
函数add\u to\u cart\u dofollow($html,$product){
如果($product->product_type=='simple'){
$html=sprintf(“”,
esc_url($product->add_to_cart_url()),
esc_属性(isset($数量)?$数量:1),
esc_attr($product->get_id()),
esc_attr($product->get_sku()),
esc_attr(isset($args['class'])?$args['class']:“按钮产品类型变量添加到购物车按钮”),
esc_attr(isset($args['attributes'))?wc_内爆html_attributes($args['attributes'):“”),
esc_html($product->add_to_cart_text())
);
}否则{
$html=sprintf(“”,
esc_url($product->add_to_cart_url()),
esc_属性(isset($数量)?$数量:1),
esc_attr($product->get_id()),
esc_attr($product->get_sku()),
esc_attr(isset($args['class'])?$args['class']:“按钮产品类型变量添加到购物车按钮”),
esc_attr(isset($args['attributes'))?wc_内爆html_attributes($args['attributes'):“”),
esc_html($product->add_to_cart_text())
);
}
返回$html;
}

我使用这个代码。但没有找到如何在“aria标签”中插入产品标题

// Change rel “nofollow” to rel “dofollow” on Shop Page Product button
add_filter( 'woocommerce_loop_add_to_cart_link', 'add_to_cart_dofollow', 10, 2 );
function add_to_cart_dofollow($html, $product){
    if($product->product_type == 'simple') {
        $html = sprintf( '<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" aria-label="Добавить в корзину" data-product_sku="%s" class="%s" %s>%s</a>',
        esc_url( $product->add_to_cart_url() ),
        esc_attr( isset( $quantity ) ? $quantity : 1 ),
        esc_attr( $product->get_id() ),
        esc_attr( $product->get_sku() ),
        esc_attr( isset( $args['class'] ) ? $args['class'] : 'button product_type_variable add_to_cart_button' ),
        esc_attr( isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : ''),
        esc_html( $product->add_to_cart_text() )
    );
    }else {
    $html = sprintf( '<a href="%s" data-quantity="%s" data-product_id="%s" aria-label="Выбрать" data-product_sku="%s" class="%s" %s>%s</a>',
        esc_url( $product->add_to_cart_url() ),
        esc_attr( isset( $quantity ) ? $quantity : 1 ),
        esc_attr( $product->get_id() ),
        esc_attr( $product->get_sku() ),
        esc_attr( isset( $args['class'] ) ? $args['class'] : 'button product_type_variable add_to_cart_button' ),
        esc_attr( isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : ''),
        esc_html( $product->add_to_cart_text() )
    );
    }
    return $html;
}
//将商店页面产品按钮上的rel“nofollow”更改为rel“dofollow”
添加过滤器('woocommerce\u loop\u add\u to \u cart\u link'、'add\u to \u cart\u dofollow',10,2);
函数add\u to\u cart\u dofollow($html,$product){
如果($product->product_type=='simple'){
$html=sprintf(“”,
esc_url($product->add_to_cart_url()),
esc_属性(isset($数量)?$数量:1),
esc_attr($product->get_id()),
esc_attr($product->get_sku()),
esc_attr(isset($args['class'])?$args['class']:“按钮产品类型变量添加到购物车按钮”),
esc_attr(isset($args['attributes'))?wc_内爆html_attributes($args['attributes'):“”),
esc_html($product->add_to_cart_text())
);
}否则{
$html=sprintf(“”,
esc_url($product->add_to_cart_url()),
esc_属性(isset($数量)?$数量:1),
esc_attr($product->get_id()),
esc_attr($product->get_sku()),
esc_attr(isset($args['class'])?$args['class']:“按钮产品类型变量添加到购物车按钮”),
esc_attr(isset($args['attributes'))?wc_内爆html_attributes($args['attributes'):“”),
esc_html($product->add_to_cart_text())
);
}
返回$html;
}

Hi,为什么woocommerce添加nofollow on添加到购物车按钮?你知道为什么吗?因为这些链接不应该被搜索引擎编入索引。嗨,为什么woocommerce添加nofollow-on添加到购物车按钮?你知道为什么吗?因为这些链接不应该被搜索引擎索引。