如何解决如何仅将nofollow添加到首页? Woocommerce产品,内部链接
当前它在网站上的所有产品上都添加了nofollow,如何仅在is_front_page()上添加它?..
function woocommerce_template_loop_product_title() {
echo '<p class="name product-title ' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes','woocommerce-loop-product__title' ) ) . '"><a href="' . get_the_permalink() . '" rel="nofollow">' . get_the_title() . '</a></p>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
解决方法
更改您的rel
属性的值。因此,当用户位于frontpage
时,rel
的值为nofollow
。否则,该值将为""
为空。
<?php
function woocommerce_template_loop_product_title() {
// Add the $nofollow
$nofollow = "";
if(is_front_page() ){
$nofollow = "nofollow";
}
echo '<p class="name product-title ' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes','woocommerce-loop-product__title' ) ) . '"><a href="' . get_the_permalink() . '" rel='.$nofollow.'>' . get_the_title() . '</a></p>';
?>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。