Set a Custom Post Type as a Homepage

There is a lot of nuance here, depending on what exactly you want to accomplish. I don’t feel confident I completely grasp it from your question.

In general WP logic flow is following:

  • URL is converted to query vars
  • query vars go into main query instance
  • main query instance queries posts
  • template loader uses conditional tags (which use main query) to determine template
  • template runs loop over main query

You seem to want two things: to have home page display CPTs and have home page use special template for them. So there are two things you need to adjust: posts queried and template used.

Basic implementation might look like this:

class Stacks {

    public function __construct() {

        add_action( 'init', array( $this, 'init' ) );
        add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
        add_action( 'template_include', array( $this, 'template_include' ) );
    }

    public function init() {

        // your registration code
    }

    public function pre_get_posts( $wp_query ) {

        if ( $wp_query->is_main_query() && $wp_query->is_home() ) {
            $wp_query->set( 'post_type', 'stacks' );
        }
    }

    public function template_include() {

        if ( is_home() ) {
            return get_stylesheet_directory() . '/stacks.php';
        }
    }
}

$stacks = new Stacks();

Note that CPTs are not created equal with native post types. Despite similar mechanics native types are “special” and there are often quirks and behaviors specific to them when you want to diverge from default operation.

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş