I am working on a theme where I would like users to be able to select pages to show in the theme options page much like Thesis.

I've been Googling / reverse engineering Thesis for a couple hours but haven't found a great solution. I am wondering if anyone has done this or has seen a tutorial.

alt text


This is how I do it in a custom theme:

<h3>Select pages to include in menu:</h3>

$page_ids = get_all_page_ids();
$current_selected = get_option("pages_to_include");

foreach( $page_ids as $page_id ) {
    if( get_post_status( $page_id ) == 'publish' ) {
        $checked = ( !empty( $current_selected ) && in_array( $page_id, $current_selected ) ) ? ' checked="checked"' : '';
        echo '<input type="checkbox" name="page_to_include[]" id="page-' . $page_id . '" value="' . $page_id . '"' . $checked . ' /> <label for="page-' . $page_id . '">' . get_the_title( $page_id ) . '</label><br />';

You store the pages list in an option (here is "pages_to_include").

  • Excellent I'll give it a shot! – abrudtkuhl Oct 3 '10 at 17:35

Since WordPress 3.0 there has been a custom menu feature, does that fit your needs? Or something in it that doesn't fit your needs? See Appearance Menus SubPanel in the WordPress codex

  • I need this functionality in an admin options page so the user can select pages to include in a slider – abrudtkuhl Oct 5 '10 at 13:18
  • Doesn't custom menus do this, minus the fact that it will always be under Appearance > Menus (to be honest I have not used them yet)? I'd assume it's better to not reinvent the wheel if not needed as users should be looking there for customizing a menu (if your target is WordPress 3.0 or newer). – mtekk Oct 6 '10 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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