Title: Add a page programatically
Last modified: August 20, 2016

---

# Add a page programatically

 *  [charleyramm](https://wordpress.org/support/users/charleyramm/)
 * (@charleyramm)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/add-a-page-programatically-1/)
 * 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.

 * 0 replies
 * 1 participant
 * Last reply from: [charleyramm](https://wordpress.org/support/users/charleyramm/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/add-a-page-programatically-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
