diff --git a/functions.php b/functions.php index 19e15663c0..6ba1c2e4e5 100644 --- a/functions.php +++ b/functions.php @@ -302,13 +302,25 @@ function render_related_posts_block(array $attributes): string // Encode the query attributes to JSON for the block template $query_json = wp_json_encode($attributes['query_attributes'], JSON_UNESCAPED_SLASHES); + // Dynamically render link to News & Stories page + $news_stories_url = ''; + $news_stories_page = (int) get_option('page_for_posts'); + + if ($news_stories_page) { + $news_stories_url = get_permalink($news_stories_page); + } + + $see_all_link_group = !empty($news_stories_url) ? + '' + : ''; + // Define the HTML output for the block $output = '
@@ -328,7 +340,8 @@ function render_related_posts_block(array $attributes): string
- + ' . $see_all_link_group . ' + '; return do_blocks($output);