bp_get_blog_latest_post( array $args = array() )

Return the latest post from the current blog in the loop.

Description

Parameters

$args

(Optional) Array of optional arguments.

  • 'latest_format'
    (bool) If true, formatted "Latest post: [link to post]". If false, formatted "[link to post]". Default: true.

Default value: array()

Return

(string) $retval String of the form 'Latest Post: [link to post]'.

Source

File: bp-blogs/bp-blogs-template.php

692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
function bp_get_blog_latest_post( $args = array() ) {
    global $blogs_template;
 
    $r = wp_parse_args( $args, array(
        'latest_format' => true,
    ) );
 
    $retval = bp_get_blog_latest_post_title();
 
    if ( ! empty( $retval ) ) {
        if ( ! empty( $r['latest_format'] ) ) {
 
            /**
             * Filters the title text of the latest post for the current blog in loop.
             *
             * @since BuddyPress 1.0.0
             *
             * @param string $retval Title of the latest post.
             */
            $retval = sprintf( __( 'Latest Post: %s', 'buddyboss' ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' );
        } else {
 
            /** This filter is documented in bp-blogs/bp-blogs-template.php */
            $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>';
        }
    }
 
    /**
     * Filters the HTML markup result for the latest blog post in loop.
     *
     * @since BuddyPress 1.2.0
     * @since BuddyPress 2.6.0 Added the `$r` parameter.
     *
     * @param string $retval HTML markup for the latest post.
     * @param array  $r      Array of parsed arguments.
     */
    return apply_filters( 'bp_get_blog_latest_post', $retval, $r );
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.