Ok, since we’re going the post meta route (as opposed to options), there’s a much cleaner and efficient way to grab a post by it’s title:
if ( $info = get_page_by_title( 'Business Info', OBJECT, 'post' ) ) {
// do stuff
}
Don’t let the page
in the function name throw you off – the third argument is the post type (in this case post
).
Secondly, let’s find out what’s actually going on:
if ( $info = get_page_by_title( 'Business Info', OBJECT, 'post' ) ) {
echo '<pre>';
echo esc_html( print_r( get_post_meta( $info->ID ), true ) );
echo '</pre>';
} else {
echo 'Oh no!';
}
Report back with you what you get from the above debugging snippet.