Need help in changing the output of wp_dropdown_pages
-
Hello there,
I was working on this for a while now and I can’t seem to wrap my head around this. I have a customer who would like to have a drop down list of pages when they create a new post.
What the drop down list would do is add the post title of that selected page to the body of the content. I’ve manage to get a working meta box with the following code that will insert the selected page id into the body.
My problem is that I want the post title to be inserted instead of the post id.
Here is the code I’m using in a plugin:
function dr_meta_boxes() { global $post; echo "<script style=\"text/javascript\"> jQuery(function($) { $('#daily_regulars').change(function() { var value = $('#content').val(); $('#content').val( value + (value != '<ul><li>' ? '<li>' : '') +$(this).find('option:selected').val() +(value != '</li>' ? '</li>' : '')); }); }); </script>"; wp_dropdown_pages(array('child_of' => '225', 'name' => 'daily_regulars')); echo '<br />'; } function create_dr_meta_box() { global $theme_name; if ( function_exists('add_meta_box') ) { add_meta_box( 'dr-meta-boxes', 'Regulars of the day', 'dr_meta_boxes', 'post', 'normal', 'high' ); } } add_action('admin_menu', 'create_dr_meta_box');
- The topic ‘Need help in changing the output of wp_dropdown_pages’ is closed to new replies.