I was looking at the way WordPress uses "Or Link to Existing Content" under the link button in the editor and I am wondering if there is any way I can use that code to allow users to select a page to link to when they create a new custom post.

The context I am talking about is that of slides for a slider linking to content within the site.

1 Answer 1


I've run across this before. What I did was use get_posts() to return a list of the pages in the site and making the pages options in a drop down menu in a meta box.

// $your_args is an array that you've previously declared to get all the pages.
$pages = get_posts($your_args);

foreach( $pages as $page ) :
<option value="<?php echo $page->ID; ?>"><?php echo $page->post_name; ?></option>

When you save the post, it will save the page's ID in the custom post's post meta.

  • Thanks, I'm sure this is probably the best available method but I was hoping to get something that handles 1000's of posts; and I'd say it would take a bit of ajax or something to implement that properly, rather than having a huge list. I think I will just let people copy and paste for now. Commented Jun 18, 2012 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.