bp_get_blog_latest_post

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

Description

(string) bp_get_blog_latest_post( (array) $args = array() ); 

Returns (string)

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

Parameters (1)

0. $args — Optional. (array) => array()
Array of optional arguments.

Options

    ;        


    Usage

    1. if ( !function_exists( 'bp_get_blog_latest_post' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-template.php'; 
    3.  
    4. // Array of optional arguments. 
    5. $args = array(); 
    6.  
    7. // NOTICE! Understand what this does before running. 
    8. $result = bp_get_blog_latest_post($args); 
    9.  

    Defined (1)

    The function is defined in the following location(s).

    /bp-blogs/bp-blogs-template.php  
    1. function bp_get_blog_latest_post( $args = array() ) { 
    2. global $blogs_template; 
    3.  
    4. $r = wp_parse_args( $args, array( 
    5. 'latest_format' => true,  
    6. ) ); 
    7.  
    8.  
    9. if ( ! empty( $retval ) ) { 
    10. if ( ! empty( $r['latest_format'] ) ) { 
    11.  
    12. /** 
    13. * Filters the title text of the latest post for the current blog in loop. 
    14. * @since 1.0.0 
    15. * @param string $retval Title of the latest post. 
    16. */ 
    17. $retval = sprintf( __( 'Latest Post: %s', buddypress ), '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>' ); 
    18. } else { 
    19.  
    20. /** This filter is documented in bp-blogs/bp-blogs-template.php */ 
    21. $retval = '<a href="' . $blogs_template->blog->latest_post->guid . '">' . apply_filters( 'the_title', $retval ) . '</a>'; 
    22.  
    23. /** 
    24. * Filters the HTML markup result for the latest blog post in loop. 
    25. * @since 1.2.0 
    26. * @since 2.6.0 Added the `$r` parameter. 
    27. * @param string $retval HTML markup for the latest post. 
    28. * @param array $r Array of parsed arguments. 
    29. */ 
    30. return apply_filters( 'bp_get_blog_latest_post', $retval, $r );