-
AuthorPosts
-
January 6, 2015 at 10:02 am #177722
Hi,
I would like to make my footer menu nofollow. Same goes for some buttons. I have buttons linking to amazon. I would like to make those nofollow.
How can I do that?
January 6, 2015 at 12:31 pm #177836Hi there,
If you want to add nofollow attribute on [button] shortcodes, it requires a template case. I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.
After that, add following code in your child theme’s functions.php file:
// Buttons - Adding nofollow attribute // ============================================================================= function x_shortcode_button2( $atts, $content = null ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'type' => '', 'shape' => '', 'size' => '', 'float' => '', 'block' => '', 'circle' => '', 'icon_only' => '', 'href' => '', 'title' => '', 'target' => '', 'info' => '', 'info_place' => '', 'info_trigger' => '', 'info_content' => '', 'lightbox_thumb' => '', 'lightbox_video' => '', 'lightbox_caption' => '', 'no_follow' => '' ), $atts ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? ' ' . esc_attr( $class ) : ''; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $type = ( $type != '' ) ? ' x-btn-' . $type : ''; $shape = ( $shape != '' ) ? ' x-btn-' . $shape : ''; $size = ( $size != '' ) ? ' x-btn-' . $size : ''; switch ( $float ) { case 'left' : $float = ' alignleft'; break; case 'right' : $float = ' alignright'; break; default : $float = ''; } $block = ( $block == 'true' ) ? ' x-btn-block' : ''; $icon_only = ( $icon_only == 'true' ) ? ' x-btn-icon-only' : ''; $href = ( $href != '' ) ? $href : '#'; $title = ( $title != '' ) ? 'title="' . $title . '"' : ''; $target = ( $target == 'blank' ) ? 'target="_blank"' : ''; $info = ( $info != '' ) ? 'data-toggle="' . $info . '"' : ''; $info_place = ( $info_place != '' ) ? 'data-placement="' . $info_place . '"' : ''; $info_trigger = ( $info_trigger != '' ) ? 'data-trigger="' . $info_trigger . '"' : ''; $info_content = ( $info_content != '' ) ? 'data-content="' . $info_content . '"' : ''; $lightbox_thumb = ( $lightbox_thumb != '' ) ? $lightbox_thumb : ''; $lightbox_video = ( $lightbox_video == 'true' ) ? ', width: 1080, height: 608' : ''; $lightbox_caption = ( $lightbox_caption != '' ) ? 'data-caption="' . $lightbox_caption . '"' : ''; $no_follow = ( $no_follow == 'true' ) ? 'rel="nofollow"' : ''; if ( is_numeric( $lightbox_thumb ) ) { $lightbox_thumb_info = wp_get_attachment_image_src( $lightbox_thumb, 'full' ); $lightbox_thumb = $lightbox_thumb_info[0]; } if ( $lightbox_video != '' ) { $lightbox_options = "data-options=\"thumbnail: '" . $lightbox_thumb . "'{$lightbox_video}\""; } else { $lightbox_options = "data-options=\"thumbnail: '" . $lightbox_thumb . "'\""; } if ( $circle == 'true' ) { $output = "<div {$id} class=\"x-btn-circle-wrap{$size}{$block}{$float}\" {$style}><a class=\"x-btn{$class}{$type}{$shape}{$size}{$block}{$icon_only}\" href=\"{$href}\" {$no_follow} {$title} {$target} {$info} {$info_place} {$info_trigger} {$info_content} {$lightbox_caption} {$lightbox_options}>" . do_shortcode( $content ) . "</a></div>"; } else { $output = "<a {$id} class=\"x-btn{$class}{$type}{$shape}{$size}{$block}{$float}{$icon_only}\" {$style} href=\"{$href}\" {$no_follow} {$title} {$target} {$info} {$info_place} {$info_trigger} {$info_content} {$lightbox_caption} {$lightbox_options}>" . do_shortcode( $content ) . "</a>"; } return $output; } add_filter('init', function() { remove_shortcode( 'button' ); add_shortcode( 'button', 'x_shortcode_button2' ); });
Now, simply add a attribute of
no_follow="true"
to your button shortcode when you want to add nofollow links. E.g:[button shape="square" size="mini" no_follow="true"]Hello World![/button]
Thanks!
-
AuthorPosts