admin管理员组

文章数量:1329040

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>

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>
Share Improve this question edited Jul 29, 2020 at 6:03 Botond Vajna asked Jul 29, 2020 at 5:51 Botond VajnaBotond Vajna 4714 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: Display the date before the post title in recent posts widget