We have a group of pages that will not appear in the main nav menu but need to be presented on a single page as a drop-down jump menu. I chose this method to 'keep it simple' for the intern since he will just have to create the gallery, add a page, insert the shortcode and a custom field. I am also using this method so that the drop-down list is dynamic and will accomodate added pages on the fly.
On the template page, I added this code:
<div id="right_side_nav">
<?php
$media_artists = $wpdb->get_results("SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key = 'Media_Room_Title' ORDER BY 'meta_value'");
foreach( $media_artists as $arty ):
echo $arty->meta_value . " ( " . $arty->post_id . " )<br><br>";
endforeach; ?>
</div> <!-- END right_side_nav -->
So far, so good. I get the list and as another page with the proper custom field is added, the list dynamically adds it.
My question ... how do I create the anchor tag using the post_id?
I looked in the Codex for paths to pages/posts based on post_id but everything seemed to be about redirecting pages after changing the default structure.