• Here’s my code for the custom post type:

    function create_post_type() {
    	register_post_type( 'galactic_gallery',
    		array(
    		'labels' => array(
    			'name' => __( 'Gallery' ),
    			'singular_name' => __( 'Gallery Post' ),
    		),
    		'rewrite' => array( 'slug' => 'gallery', 'with_front' => false ),
    		'public' => true,
    		'menu_position' => 4,
    		'has_archive' => true,
    		'hierarchical' => true,
    		'supports' => array( 'title', 'editor', 'thumbnail', 'comments' ),
    		'taxonomies' => array( 'post_tag', 'category'),
    		)
    	);
    	flush_rewrite_rules( false );
    }
    add_action( 'init', 'create_post_type' );

    I have single post template called single-galactic_gallery.php and that works. I have a page called archive-galactic_gallery.php and my gallery posts, when I click on a tag or a category, are not going there. Any help would be appreciated. Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Justin Carroll

    (@3circlestudio)

    Maybe since I’m using taxonimies of ‘post_tag’ and ‘category’ which are also being used by posts when I click on the category or tag for a custom post type it’s using the default index.php for that?

    I have the same query and custom post type setup and am having the exact same problem. Can’t figure it out. Have you gotten a response to your issue through another forum?

    I also have a same problem. waiting for reply.

    same issue here

    Thread Starter Justin Carroll

    (@3circlestudio)

    I wrote a definitive post about custom post type pagination over at wptuts, check it out!

    adding ‘has_archive’ => true when I register my post type as mentioned here solved my problems.

    I’ve read this topic and I can’t resolved same problem.
    I have functions.php with code:

    add_action( 'init', 'create_zombie_post_type' );
    function create_zombie_post_type()
    {
    	register_post_type('zombies',
    		array(
    			'label' => 'Zombies',
    			'public' => true,
    			'has_archive' =>true
    		)
    	);
    }

    I have single template called single-zombies.php and that works.
    I have archive.php template and archive-zombies.php template. I have permalinks in Custom Structer like /%postname%/. I try URL https://localhost/wordpress/zombies and It is not working because I see 404 page.
    Where is my mistake? Have I problem with URL or code inside functions.php?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    function create_zombie_post_type() {
    	register_post_type( 'zombies',
    		array(
    		'labels' => array(
    			'name' => __( 'Zombies' ),
    			'singular_name' => __( 'Zombie Post' ),
    		),
    		'rewrite' => array( 'slug' => 'zombies', 'with_front' => true ),
    		'public' => true,
    		'has_archive' => true,
    
    		)
    	);
    	flush_rewrite_rules( false );
    }
    add_action( 'init', 'create_zombie_post_type' );

    Thanks for that Ipstenu.

    flush_rewrite_rules(false); — this is something you need to include whenever you create a custom post type with an archive?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom Post Type Archive Template Not Working’ is closed to new replies.