remove the title attribute from links

admin2025-06-06  3

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I'm looking for a way to remove the title attribute from links. There is a old plugin but it breaks the site.

The title I would like to remove is in the sidebar widget. Thats the code of the widget part:

    // Coupon Catetories Widget
class CLPR_Widget_Coupon_Categories extends WP_Widget {

    function __construct() {
        $widget_ops = array( 'description' => __( 'Display the coupon categories.', APP_TD ), 'classname' => 'widget-coupon-cats' );
        parent::__construct( 'coupon-cats', __( 'Clipper Coupon Categories', APP_TD ), $widget_ops );
    }

    function widget($args, $instance) {
        global $wpdb;
        extract( $args );
        $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Coupon Categories', APP_TD ) : $instance['title']);

        if (strpos($before_widget, 'customclass') !== false)
            $before_widget = str_replace('customclass', 'cut', $before_widget);
        else
            $before_widget = str_replace('customclass', '', $before_widget);

        echo $before_widget;

        if ( $title ) echo $before_title . $title . $after_title;

            $tax_name = APP_TAX_CAT;
            echo '<div class="coupon-cats-widget"><ul class="list">';

            wp_list_categories("orderby=name&order=asc&hierarchical=1&show_count=0&pad_counts=0&app_pad_counts=1&hide_empty=0&depth=1&number=&title_li=&taxonomy=$tax_name");

            echo '</ul></div>'; 

        echo $after_widget;
    }

    function update($new_instance, $old_instance) {
        return $new_instance;
    }

    function form($instance) {
        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
        $title = esc_attr($instance['title']);
        ?>
            <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', APP_TD ); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
        <?php
    }
}
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I'm looking for a way to remove the title attribute from links. There is a old plugin but it breaks the site.

The title I would like to remove is in the sidebar widget. Thats the code of the widget part:

    // Coupon Catetories Widget
class CLPR_Widget_Coupon_Categories extends WP_Widget {

    function __construct() {
        $widget_ops = array( 'description' => __( 'Display the coupon categories.', APP_TD ), 'classname' => 'widget-coupon-cats' );
        parent::__construct( 'coupon-cats', __( 'Clipper Coupon Categories', APP_TD ), $widget_ops );
    }

    function widget($args, $instance) {
        global $wpdb;
        extract( $args );
        $title = apply_filters('widget_title', empty($instance['title']) ? __( 'Coupon Categories', APP_TD ) : $instance['title']);

        if (strpos($before_widget, 'customclass') !== false)
            $before_widget = str_replace('customclass', 'cut', $before_widget);
        else
            $before_widget = str_replace('customclass', '', $before_widget);

        echo $before_widget;

        if ( $title ) echo $before_title . $title . $after_title;

            $tax_name = APP_TAX_CAT;
            echo '<div class="coupon-cats-widget"><ul class="list">';

            wp_list_categories("orderby=name&order=asc&hierarchical=1&show_count=0&pad_counts=0&app_pad_counts=1&hide_empty=0&depth=1&number=&title_li=&taxonomy=$tax_name");

            echo '</ul></div>'; 

        echo $after_widget;
    }

    function update($new_instance, $old_instance) {
        return $new_instance;
    }

    function form($instance) {
        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
        $title = esc_attr($instance['title']);
        ?>
            <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title:', APP_TD ); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
        <?php
    }
}
Share Improve this question edited Nov 27, 2018 at 21:53 joloshop asked Nov 27, 2018 at 20:44 joloshopjoloshop 211 silver badge8 bronze badges 8
  • Can you ellaborate a little as to why you are trying to do this? What problem does it solve? – Tom J Nowell Commented Nov 27, 2018 at 21:35
  • I can not change certain description from taxonomy categories and the title=shows irritating content. Therefore I need to remove it. Also for SEO Reason. – joloshop Commented Nov 27, 2018 at 21:39
  • Whoever told you it affected SEO was talking BS. Would it not have been better to ask how to change those descriptions? Pretty much everything can be changed, even if it isn't clear how. Additionally, by understanding where the title attributes and links are, you might get a better answer. Right now the assumption is that you want them removed from links inside post content, or, the super old links table functionality – Tom J Nowell Commented Nov 27, 2018 at 21:42
  • They are located in a custom category list in one of the sidebar widgets. – joloshop Commented Nov 27, 2018 at 21:50
  • How is the custom category list widget implemented? – Tom J Nowell Commented Nov 28, 2018 at 1:38
 |  Show 3 more comments

1 Answer 1

Reset to default 1

You could provide some more details, like what title attributes you are trying to remove. In the navigation, content, etc. Anyway, you could try adding this to your theme or child theme's functions.php file, I have yet to test it though.

function remove_title_attributes($input) {
    return preg_replace('/\s*title\s*=\s*(["\']).*?\1/', '', $input);
}
add_filter('wp_list_pages', 'remove_title_attributes');
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749147471a316770.html

最新回复(0)