Feeds: Add an optional $post parameter to get_the_title_rss().

This allows the function to be used outside of the loop and brings parity with `get_the_title()`.

Follow-up to [1976], [3314], [21735].

Props khokansardar, oglekler.
Fixes #61139.

git-svn-id: https://develop.svn.wordpress.org/trunk@58096 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2024-05-04 19:09:57 +00:00
parent 121e5d69d7
commit 4a256357e9

View File

@ -150,11 +150,13 @@ function wp_title_rss( $deprecated = '–' ) {
* Retrieves the current post title for the feed.
*
* @since 2.0.0
* @since 6.6.0 Added the `$post` parameter.
*
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
* @return string Current post title.
*/
function get_the_title_rss() {
$title = get_the_title();
function get_the_title_rss( $post = 0 ) {
$title = get_the_title( $post );
/**
* Filters the post title for use in a feed.