Access wordpress post data outside the loop

December 6, 2008

How he can access post data outside the loop? paste the following function on the functions.php file from your theme. This function takes a singles argument, which is the ID of the post you’d like to access data. It will return an array, containing post title, date, content, author id, post id, etc. function get_post_data($postId) { global $wpdb; return $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID=$postId"); } To use the function, use the following anywhere on your theme files: <?php $data =... [Read the full story]

Page 1 of 11