2

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

2

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.

2
  • 1
    thank you, as a workaround, I used CSS flexbox: ```` .widget_recent_entries li { display: flex; flex-wrap: wrap-reverse; } ```` Jul 30, 2020 at 9:21
  • Neat! Don't you just love it when there are a lot of solutions for a problem? Jul 31, 2020 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.