bp_get_blog_latest_post( array $args = array() )

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


Parameters Parameters

$args

(array) (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()


Top ↑

Return Return

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


Source Source

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

	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 1.0.0
				 *
				 * @param string $retval Title of the latest post.
				 */
				$retval = sprintf(
					/* translators: %s: the title of the latest post */
					__( 'Latest Post: %s', 'buddypress' ),
					'<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 1.2.0
		 * @since 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 );
	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.