wordpress - Display custom post using ID -
in theme, have custom post type called sliders. here user allowed upload images in meta-box. so, images saved meta data in wp_post_meta table.
now want is, displaying slider using id.
i did following no result
$my_query = new wp_query('post_type=sliders&p=411'); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); the_post(); endwhile; } this doesn't display anything. no errors. anyway, if used the_title() instead of the_post(), shows title of slider fine. same the_author() shows author without error.
why weird ?
according codex the_post(); :
the_post();iterate post index in loop. retrieves next post, sets post, sets 'in loop' property true. this function not return values.
example how use function:
<?php if ( have_posts() ) { while ( have_posts() ) { the_post(); he_title(); the_content(); } } ?> you didn't explain question. anyway display metabox use api function
echo get_post_meta( $id, 'metabox_name', true );
Comments
Post a Comment