Support » Fixing WordPress » Custom post type archive as front page

  • leemon



    Is there any easy way to setup a custom post type archive as the front page in WP? I know I can create a template that modifies the post query to retrieve custom posts instead of normal posts, but I’m wondering if there’s a simpler way to do this.

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • s_ha_dum


    Probably not. You could create a “Page” with the same name as your custom post archive slug, set that as the static front page, and see if it doesn’t confuse things in the just the right way 🙂

    You will get better performance if you interrupt the main query with the post_* filters rather than create a new query.

    Marco Panichi


    Put this code (after replacing <MYTYPE> with you cpt name) into your functions.php:

    function add_<MYTPE>_to_dropdown( $pages, $r )
    	if('page_on_front' == $r['name'])
    		$args = array(
    			'post_type' => '<MYTYPE>'
    		$items = get_posts($args);
    		$pages = array_merge($pages, $items);
    	return $pages;
    add_filter( 'get_pages', 'add_<MYTPE>_to_dropdown' );
    function enable_front_page_<MYTPE>( $query )
    	if('' == $query->query_vars['post_type'] && 0 != $query->query_vars['page_id'])
    		$query->query_vars['post_type'] = array( 'page', '<MYTPE>' );
    add_action( 'pre_get_posts', 'enable_front_page_<MYTPE>' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom post type archive as front page’ is closed to new replies.