StudioPress Community Forums

StudioPress Community Forums (http://www.studiopress.com/support/index.php)
-   General Discussion (http://www.studiopress.com/support/forumdisplay.php?f=7)
-   -   Display info from a specific custom post (http://www.studiopress.com/support/showthread.php?t=121735)

motty07 10-22-2012 01:36 PM

Display info from a specific custom post
 
Hi

I'm trying to display details from a specific custom post (using a post id) in the sidebar.

The code I'm using (just a starter test) is:

PHP Code:

function sidebar_photo_advert_static()
{
    
$spas_loop = new WP_query('p=7022');
    while ( 
$spas_loop->have_posts() ) : $spas_loop->the_post();
    echo 
'<li>';
    
the_title();
    echo 
'</li>';
endwhile;


It works fine if 7022 is a regular 'post', but not if is a custom post (say type = adverts). Any ideas on the query I need to use for a specific custom post type where the type is 'adverts' and the id 7022.?

NicktheGeek 10-23-2012 08:07 AM

you need to se the post type.
PHP Code:

$spas_loop = new WP_query('post_type=adverts&p=7022'); 



All times are GMT -5. The time now is 10:13 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.