[wordpress][solution] How to get any post info outside the loop?

By.

min read

My profile

Share this:

Start with setting $post_id, then you query the DB and reset the query.
Now you have an array, so take the first item by [0] the post.

[code:1:67dddd27fe] $post_id = POST_ID_HERE;
$post = query_posts(’p=’.$post_id);
wp_reset_query();
$post = $post[0];[/code:1:67dddd27fe]

After this you’ll have everything you need like $post->post_title etc !

Read on:
[url]http://codex.wordpress.org.cn/Template_Tags/query_posts[/url]
[url]http://codex.wordpress.org/Template_Tags/query_posts[/url]

[url]http://stackoverflow.com/questions/1391299/getting-post-information-outside-the-wordpress-loop[/url]

[url]http://www.mydigitallife.info/2006/06/24/retrieve-and-get-wordpress-post-id-outside-the-loop-as-php-variable/[/url]
[url]http://www.lonewolfdesigns.co.uk/excerpt-loop/[/url]
[url]http://ifelse.co.uk/archives/2005/04/08/query_posts-redux/[/url]
[url]http://www.jtpratt.com/wordpress-hack-1-query_posts/[/url]
[url]http://www.livexp.net/wordpress/access-wordpress-post-data-outside-the-loop.html[/url]
[url]http://www.optiniche.com/blog/15/the-wordpress-loop-and-adding-content-outside-of-it/[/url]
[url]http://mywordpress.com/get-post-title-outside-the-loop/[/url]

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *