• Resolved charlie67p

    (@charlie67p)


    Hi!

    Using the Post Navigation Link block :

    Is it possible to show the dates of the previous and next posts next to their titles ?
    Any hook to do that ?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter charlie67p

    (@charlie67p)

    OK, I managed to display the date with a custom shortcode (below).

    Now I would like to display the date inside the post link, right after the Title.

    – The get_adjacent_post_rel_link function might be the key

    – Or could I achieve that modifying the render of the Post Navigation Link Block ?

    … Any idea ?

    Thanks

    add_shortcode('prevpostdate', 'prevpostdate_func');
    function prevpostdate_func()
    {
    $in_same_cat = false;
    $excluded_categories = '';
    $previous = true;
    $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);
    $daterecup = $post->post_date;
    return mysql2date("d F Y", $daterecup, true);
    }

    • This reply was modified 1 year, 5 months ago by charlie67p.
    • This reply was modified 1 year, 5 months ago by charlie67p.
    Thread Starter charlie67p

    (@charlie67p)

    I finally did it with my custom shortcode
    next_post_link('<div class="post-navigation-link-next">%link</div>', $TitleNextDate);
    where $TitleNextDate is getting $post->post_title and $post->post_date

    [ the Post Navigation Link block could be improved with a ”showDate” attribute…]

    • This reply was modified 1 year, 5 months ago by charlie67p.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add posts dates to the Post Navigation Link block’ is closed to new replies.