Clickable Widget Titles
-
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 6 years, 1 month ago by
verseleo.
-
This topic was modified 6 years, 1 month ago by
-
Hello,
You can use the same method because oceanwp using the standard method to register the widget.
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
Can you please try to remove the
esc_htmlfrom the code and see if it works or not?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?No, you have to modify the plugin file which is not a good solution.
The topic ‘Clickable Widget Titles’ is closed to new replies.