ridesign
Member
Posted 2 years ago #
I am running a custom query using a select, and I have got a list of post id's, how can I get all of the post information for these post's?
do I need to do setup_postdata? as I could not get it working?
I want to be able to use the tempalte tags such as : the_title();
etc..
ridesign
Member
Posted 2 years ago #
I am trying to use the following:
<?php if ( function_exists('the_tags') ) { the_tags('Tags: ', ', ', ''); } ?>
But it is not appearing
My query is : $myquery = $wpdb->get_results($hdqry);
mercuryfenix
Member
Posted 2 years ago #
yes, setup_postdata will work if the result of your query is data from the post table in wordpress
here's how i use it with get_children which returns post objects
$pdfs_args = array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'numberposts' => -1, // unlimited
'post_mime_type' => 'application/pdf'
);
$pdfs = get_children($pdfs_args);
if (!empty($pdfs))
{
echo "<h2>Literature</h2>";
foreach ($pdfs as $post) // important that it is "$post"
{
setup_postdata($post);
the_title();
// to check out what's in the object, uncomment the following line
// echo "<textarea style=\"width:100%\">". print_r($post, true). "</textarea>";
}
}
hope this helps