From ccb3b52f5c62da551a919490c1635b1d811d95a9 Mon Sep 17 00:00:00 2001 From: Osong Agberndifor <38656549+Osong-Michael@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:18:24 +0100 Subject: [PATCH] Fix Related Posts URL for see all posts (#2442) - Added code to dynamically render the right URL for see all posts - News and Stories page is now rendered if availabe and in the right language --- functions.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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 = '