Skip to content

Commit

Permalink
Use post object instead of id. (#48001)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey committed Feb 14, 2023
1 parent d6a1169 commit 3bab065
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/block-library/src/post-title/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function render_block_core_post_title( $attributes, $content, $block ) {
return '';
}

$post_ID = $block->context['postId'];
$title = get_the_title();
$post = get_post( $block->context['postId'] );
$title = get_the_title( $post );

if ( ! $title ) {
return '';
Expand All @@ -33,7 +33,7 @@ function render_block_core_post_title( $attributes, $content, $block ) {

if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
}

$classes = array();
Expand Down

1 comment on commit 3bab065

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 3bab065.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4172781631
📝 Reported issues:

Please sign in to comment.