Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #845965
    Paul R
    Moderator

    Hi,

    You can add it in your child theme’s functions.php file located at wp-content/themes/x-child/functions.php

    Please add it after this line

    // Additional Functions
    // =============================================================================

    Thanks

    #1091683
    jp0202
    Participant

    Same here, could someone share step by step for above solution.

    #1091709
    Christopher
    Moderator

    Hi there,

    Provided codes in this thread make recent posts and button shortocodes links nofollow.

    Because this requires a template change, 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.

    Please add following code in child theme’s functions.php file :

    // Recent Posts = No follow links
    // =============================================================================
    function x_shortcode_recent_posts_links_nofollow( $atts ) {
    extract( shortcode_atts( array(
    'id'          => '',
    'class'       => '',
    'style'       => '',
    'type'        => '',
    'count'       => '',
    'category'    => '',
    'offset'      => '',
    'orientation' => '',
    'no_image'    => '',
    'fade'        => ''
    ), $atts ) );
    $id            = ( $id          != ''          ) ? 'id="' . esc_attr( $id ) . '"' : '';
    $class         = ( $class       != ''          ) ? 'x-recent-posts cf ' . esc_attr( $class ) : 'x-recent-posts cf';
    $style         = ( $style       != ''          ) ? 'style="' . $style . '"' : '';
    $type          = ( $type        == 'portfolio' ) ? 'x-portfolio' : 'post';
    $count         = ( $count       != ''          ) ? $count : 3;
    $category      = ( $category    != ''          ) ? $category : '';
    $category_type = ( $type        == 'post'      ) ? 'category_name' : 'portfolio-category';
    $offset        = ( $offset      != ''          ) ? $offset : 0;
    $orientation   = ( $orientation != ''          ) ? ' ' . $orientation : ' horizontal';
    $no_image      = ( $no_image    == 'true'      ) ? $no_image : '';
    $fade          = ( $fade        == 'true'      ) ? $fade : 'false';
    $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} data-fade=\"{$fade}\">";
    $q = new WP_Query( array(
    'orderby'          => 'date',
    'post_type'        => "{$type}",
    'posts_per_page'   => "{$count}",
    'offset'           => "{$offset}",
    "{$category_type}" => "{$category}"
    ) );
    if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
    if ( $no_image == 'true' ) {
    $image_output       = '';
    $image_output_class = 'no-image';
    } else {
    $image_output       = '<div class="x-recent-posts-img">' . get_the_post_thumbnail( get_the_ID(), 'entry-' . x_get_option( 'x_stack', 'integrity' ) . '-cropped', NULL ) . '</div>';
    $image_output_class = 'with-image';
    }
    $output .= '<a rel="nofollow" class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink( get_the_ID() ) . '" title="' . esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ) . '">'
    . '<article id="post-' . get_the_ID() . '" class="' . implode( ' ', get_post_class() ) . '">'
    . '<div class="entry-wrap">'
    . $image_output
    . '<div class="x-recent-posts-content">'
    . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>'
    . '<span class="x-recent-posts-date">' . get_the_date() . '</span>'
    . '</div>'
    . '</div>'
    . '</article>'
    . '</a>';
    endwhile; endif; wp_reset_postdata();
    $output .= '</div>';
    return $output;
    }
    add_filter('init', function() {
    remove_shortcode( 'x_recent_posts' );
    add_shortcode( 'x_recent_posts', 'x_shortcode_recent_posts_links_nofollow' );
    });
    // Buttons
    // =============================================================================
    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' => ''
    ), $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 . '"' : '';
    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}\" rel=\"nofollow\" {$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}\" rel=\"nofollow\" {$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( 'x_button' );
    add_shortcode( 'x_button', 'x_shortcode_button2' );
    });

    Hope it helps.

  • <script> jQuery(function($){ $("#no-reply-120730 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>