Skip to content

Commit

Permalink
Post Title: The changes should be reflected when previewing a post (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Jul 6, 2023
1 parent 4baf207 commit 1ade4ec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 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,11 @@ function render_block_core_post_title( $attributes, $content, $block ) {
return '';
}

$post = get_post( $block->context['postId'] );
$title = get_the_title( $post );
/**
* The `$post` argument is intentionally omitted so that changes are reflected when previewing a post.
* See: https://github.com/WordPress/gutenberg/pull/37622#issuecomment-1000932816.
*/
$title = get_the_title();

if ( ! $title ) {
return '';
Expand All @@ -33,7 +36,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 ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $block->context['postId'] ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
}

$classes = array();
Expand Down

0 comments on commit 1ade4ec

Please sign in to comment.