• Resolved verseleo

    (@verseleo)


    Hello,

    How to add a function to accept the HTML code in Ocean extra’s widget title?
    I want to assign a Link to widget titles.

    Now by the below code, this option is added to WordPress widgets.

    add_filter( 'widget_title', 'accept_html_widget_title' );
    
    function accept_html_widget_title( $mytitle ) { 
      $mytitle = str_replace( '[link', '<a', $mytitle );
    $mytitle = str_replace( '[/link]', '</a>', $mytitle );
       $mytitle = str_replace( ']', '>', $mytitle );
    	return $mytitle;
    }

    Thank you very much

    • This topic was modified 4 years, 11 months ago by verseleo.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Amit Singh

    (@apprimit)

    Hello,

    You can use the same method because oceanwp using the standard method to register the widget.

    Thread Starter verseleo

    (@verseleo)

    Hi @apprimit

    Thanks for the reply.
    But I can’t find a way to change it.
    Any help can be useful in this regard.

    Here we have Ocean extra code:

    // Apply filters to the title
    $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
    
    // Before widget WP hook
    echo $args['before_widget'];
    
    // Show widget title
    if ( $title ) {
    echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
    }

    and this is default WordPress code:

    $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
    
    /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );

    It seems both are using a method but I’m sure there is a small point for it.

    Thanks

    • This reply was modified 4 years, 10 months ago by verseleo.
    • This reply was modified 4 years, 10 months ago by verseleo.
    Plugin Author Amit Singh

    (@apprimit)

    Can you please try to remove the esc_html from the code and see if it works or not?

    Thread Starter verseleo

    (@verseleo)

    @apprimit

    Thank you for your help, dear Amit. I greatly appreciate it.
    I was waiting and now It’s working very well.
    Can I run it from functions.php?

    Plugin Author Amit Singh

    (@apprimit)

    No, you have to modify the plugin file which is not a good solution.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Clickable Widget Titles’ is closed to new replies.