Display the date before the post title in recent posts widget

In the recent posts widget I have the post link first, and the post date second item, How can I change, to display the date in front of the post title?

Thank you.

register_sidebar( array(
        'name'          => __( 'Események', 'ashe' ),
        'id'            => 'esemenyek',
        'description'   => __( 'Add widgets here to appear in your sidebar.', 'ashe' ),
        'before_widget' => '<div id="%1$s" class="ashe-widget %2$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<div class="widget-title"><h2>',
        'after_title'   => '</h2></div>',
    ) );
if ( is_active_sidebar( 'esemenyek' ) ) {
        echo '<div class = "esemenyek">';
            dynamic_sidebar( 'esemenyek' );
        echo '</div>';
    }
<li>
    <a href="..post link">Post Title</a>
    <span class="post-date">2020.07.26.</span>
</li>

1 Answer
1

Unfortunately, this can’t be done with filters, as it’s hard-coded in the widget itself. You can see this here (currently latest version, referring to revision for accuracy over time).

What you can do is you can create your own widget, with the markup you wish. You can refer to this page on how to create your own custom widget.

There is a way to do this with JavaScript, but I would advice against it, as it’s not a good practice to change the page markup client side, if that can be done server side.

Leave a Comment