Wordpress child theme accessing function from functions.php returns a different result

59 views Asked by At

I’ve created a child theme of the Paloma FSE theme.

functions.php:

add_action('template_redirect', 'isPageFrontOrContact');
function isPageFrontOrContact() {
    if(is_page(55) || is_front_page()){
        return true;
    }
    return false;
}

/patterns/footer-default.php

<?php
var_dump(isPageFrontOrContact());
?>

When I invoke the isPageFrontOrContact function from /patterns/footer-default.php, the var_dump of the return value of the function always returns False.

For verification purposes, I added the add_action in functions.php. This shows me that the function is working correctly (albeit instantly shown at the top of the page). However when I manually invoke the isPageFrontOrContact() function from /patterns/footer-default.php, it does not know the page id so is_page always returns false.

Adding a var_dump of the global $post returns NULL as response.

Why is this not working when manually invoking the function declared in functions.php from my footer.php file?

0

There are 0 answers