Support » Themes and Templates » Select home page from theme options page

  • Hello Everyone,

    Thanks in advance for assisting with this issue…

    I am building a theme and I would like to offer “in the theme options page” an option dropdown menu for selecting the page to use for the home page and the blog page.

    The reason is because I am creating custom template pages for handling both – *** I understand that setting a static home page an post page is very easy under Settings –> Reading inside WP, however I plan to publish this theme publicly and some users may have problems ***

    On the theme options page, what I need to do is as follows:

    1) Inside an options menu display all published pages
    2) The user selects the page they want to use as the home page
    3) Once the theme options page is saved / updated, the selected home page will be set to use the designated “Home Page” template

    *** Same above for posts / blog page as above ***

    Any advice is much appreciated,


Viewing 1 replies (of 1 total)
  • I strongly recommend that you stick with the core API methodology of utilizing this feature with the settings –> reading.

    While I understand your discouragement that you feel that some users may have problems, it is in my opinion as someone on the theme review team that you stick with the current methods.

    However, if you are inclined, the way that the options-reading.php handles the setting of the page is as such:

    wp_dropdown_pages( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?>
    if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?><br />

    You would basically update_option ‘page_on_front’ && ‘page_for_posts’ probably ‘show_on_front’ as well the page you would want the user to have on the front. I do not know the variable it saves whether its the post->ID or slug name, you will have to set one, and look in your database for page_on_front and see how it is stored.

Viewing 1 replies (of 1 total)
  • The topic ‘Select home page from theme options page’ is closed to new replies.