I’ve got a drop down list populated with wordpress pages, what I am trying to do is store the item once it’s selected. i.e user selects the item, they then click save changes and when the page refreshes, that item will be stored.

I’ve been storing my items using scripts like below but not on the drop down list

$hero_options['pp_text_box_'.$i.'']

The reason for this is I don’t know how to implement it along with showing the wordpress page selections.

Here’s my function code

function pp_hero_image_option_callback() {
$hero_options = get_option( 'hero_options' ); 
$i=1;
$html = '<div id="upload_pp_sets">';
foreach($hero_options as $key => $values){
    if (strpos($key, '_pp_')) { 
        $html .= '<div id="ppclonedInput'.$i.'" class="ppclonedInput">';
        $html .= '<input id="cs_product_menu_pp_src_'.$i.'" type="text" size="36" name="hero_options[upload_pp_link_'.$i.']" value="' . $values . '" /> <input id="cs_product_menu_pp_src_'.$i.'_ppbutton" type="button" value="Add / Change" class="button-secondary pp-upload-button"  /> <div class="button ppremove">-</div> <input id="pp_text_box'.$i.'" class="pp_text_box" type="text" size="15" name="hero_options[pp_text_box_'.$i.']" value="' . $hero_options['pp_text_box_'.$i.''] . '" />';
        $html .= '<select name="page-dropdown"
onchange="document.location.href=this.options[this.selectedIndex].value;"> 
<option value="">' . attribute_escape(__('Select page')) . '</option> '; ?>
<?php 
    $pages = get_pages(); 
    foreach ($pages as $pagg) {
        $html .= '<option value="'.get_page_link($pagg->ID).'">';
        $html .= $pagg->post_title;
        $html .= '</option>';
    }
?>
<?php $html .= '</select>'; 
        $html .= '</div>';
        $i++;
    }
}
$html .= '</div><div class="button ppclone">Add an Image</div>';
echo $html; 
}

Any ideas?

Read more here: Save drop down list selection in wordpress admin’s theme page


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , ,

Wordpress related questions and answers: