Q. Want to get something in your theme to work with data from a particular page or post – but don’t know for sure what that post’s ID is?
A. Try this in your functions.php file:
$my_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = 'myPost'");
…then you can then pass a variable about in your theme’s templates.
Last updated on 5th September 2018
Leave a Reply