Make WordPress Core

Opened 4 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#61139 closed enhancement (fixed)

Add an optional $post parameter to get_the_title_rss() the same way get_the_title() works

Reported by: oglekler's profile oglekler Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.6 Priority: normal
Severity: normal Version:
Component: Feeds Keywords: good-first-bug has-patch
Focuses: Cc:

Description

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.

Change History (4)

#1 @SergeyBiryukov
4 weeks ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 6.6

This ticket was mentioned in PR #6501 on WordPress/wordpress-develop by @khokansardar.


4 weeks ago
#2

  • Keywords has-patch added; needs-patch removed

Trac ticket: #61139

#3 @SergeyBiryukov
3 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 58096:

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.

@SergeyBiryukov commented on PR #6501:


3 weeks ago
#4

Thanks for the PR! Merged in r58096.

Note: See TracTickets for help on using tickets.