shortcode inside post called by ID does not render as expected

Question

Hallo i get a post in the theme like this:

$footer_post = get_post(pll_get_post(620));
echo $footer_post->post_content; // Load contents of the page

That shows the content of post(620) in the footer.

in the functions.php i have:

function year_shortcode() {
$year = date('Y');
return $year;}
add_shortcode('YEAR', 'year_shortcode');

The problem is, when i write [YEAR] and try to use the shorcode in that specific post, it will render like [YEAR] instead of 2019. Is this a bug or do i have to make a change to my code? When i use the shortcode in a normal site, it renders properly.

WordPress 5.2.4 latest.

0
, , taxishop 4 years 2019-11-06T16:25:09-05:00 0 Answers 70 views 0

Leave an answer

Browse
Browse