• Hi,
    I would like to add a page by defining it in my themes functions.php. My theme relies on some pages with page templates, and I would like these to be generated automatically when I install the theme, rather than adding them manually. Is there a way to do this?

    Also, I would like to hide it from the wp-admin > Pages menu.

    many thanks,
    Charley

    Edit: hiding pages from wp-admin

    //Exclude pages from the wp-admin > Pages menu
    add_filter( 'parse_query', 'exclude_pages_from_admin' );
    function exclude_pages_from_admin($query) {
        global $pagenow,$post_type;
        if (is_admin() && $pagenow=='edit.php' && $post_type =='page') {
            $query->query_vars['post__not_in'] = array('47');
        }
    }

  • The topic ‘Add a page programatically’ is closed to new replies.