• I want the user to be able to exclude pages from the navigation bar by simply ticking them off.

    I’ve created a list off all the menu items with a checkbox next to them like this:

    echo "<form method='POST' action=''>";
    wp_list_pages(array("link_before" => "<input type='checkbox' name='radio' value='$post_id' />", "title_li" => ""));
    echo "<input type='submit' name='radio_submit' />
    </form>";

    Now I need to be able to somehow have the page id inside the value of the checkbox. So when the user hits submit then the page id’s get inserted into the $exclude variable in the navigation bar so the pages get excluded.

    Any ideas how I can fetch the id’s from the generated list of navi items in the admin panel?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter chaseman

    (@chaseman)

    I figured that the wp_list_pages function has a $current_page variable.

    Is there any way I could fetch it out of it?

    global $wp_query;
    		if ( is_page() || is_attachment() || $wp_query->is_posts_page )
    			$current_page = $wp_query->get_queried_object_id();
    		$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);

    Thread Starter chaseman

    (@chaseman)

    I managed to do it this way by following an example in the documentation:

    <form method='POST' action=''>
    <select name="page-dropdown">
     <option value="">
    <?php echo attribute_escape(__('Select page')); ?></option>
     <?php
      $pages = get_pages();
      foreach ($pages as $pagg) {
      	$option = '<option value="'. $pagg->ID .'">';
    	$option .= $pagg->post_title;
    	$option .= '</option>';
    	echo $option;
      }
     ?>
    </select>
    <input type='submit' name='drop_submit' />
    </form>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting the ID From The Pages with wp_list_pages’ is closed to new replies.