Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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>
<?php
endforeach;

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

share|improve this answer
    
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. –  byronyasgur Jun 18 '12 at 21:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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