Pregunta

I want to add "Recent Posts" widget in a sidebar without a title but every time I add it, it shows "Recent Posts" text as title. How do I have it without title? I don't want to use any plugin for this.

Thank You.

¿Fue útil?

Solución

This code will set the title to an empty string if it is set to Recent Posts (Which as you noted, is what the Recent Posts widget will set the title to if it is empty):

add_filter( 'widget_title', 'wpse_widget_title', 10, 3 );
function wpse_widget_title( $title, $instance, $id_base ) {
    if ( 'recent-posts' === $id_base && __( 'Recent Posts', 'text_domain' ) === $title ) {
        $title = '';    
    }

    return $title;
}

Another workaround is to set the title to the HTML entity for a space,   in the widget editor.

Otros consejos

Go to 'Appearance -> Customize -> Additional CSS' and add:

.widget_recent_entries>h3 {
    display: none;
}

Click on 'Save&Publish'. Exit customizer.

Licenciado bajo: CC-BY-SA con atribución
scroll top