I want to see the content of the $post
object in the front end. I want to do it via functions.php
.
What I'm doing in function.php
is:
global $post;
print_r($post);
But nothing shows up in the frontend. What am I doing wrong here?
I want to see the content of the $post
object in the front end. I want to do it via functions.php
.
What I'm doing in function.php
is:
global $post;
print_r($post);
But nothing shows up in the frontend. What am I doing wrong here?
Share Improve this question edited May 3, 2020 at 15:52 Sven 3,6841 gold badge35 silver badges48 bronze badges asked May 3, 2020 at 6:17 Nayan ChowdhuryNayan Chowdhury 33 bronze badges1 Answer
Reset to default 0Because in functions.php, it is too early to just run the print_r(), you may run it within a init hook like this:
Placing it inside theme's functions.php
add_action( 'init', 'test_trace' );
function test_trace() {
global $post;
print_r($post);
}