[wp-trac] [WordPress Trac] #61139: Add an optional $post parameter to get_the_title_rss() the same way get_the_title() works
WordPress Trac
noreply at wordpress.org
Fri May 3 08:53:34 UTC 2024
#61139: Add an optional $post parameter to get_the_title_rss() the same way
get_the_title() works
-------------------------+-----------------------------
Reporter: oglekler | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Feeds | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
This will allow it to be used outside of the loop and ensure consistency:
{{{
function get_the_title_rss( $post = 0 ) {
$title = get_the_title( $post );
/**
* Filters the post title for use in a feed.
*
* @since 1.2.0
*
* @param string $title The current post title.
*/
return apply_filters( 'the_title_rss', $title );
}
}}}
Use case: I'm adding related posts to a feed item and I only need the
title, link and thumbnail, so there's no need to setup global $post and
then reset it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61139>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list