How to call a post’s metadata in shortcode.php?
The first one doesn’t work because $post doesn’t exist inside the context of your shortcode function, you would need to add global $post; before it. However… You should use get_the_ID() instead of accessing the $post global directly. The reason it doesn’t work in your second example is that it’s not a class method, it’s just … Read more