0

I create a custom post type (deals), terms (project), menu (top_menu) and archive page (archive-deals.php) on my theme. I want to display terms post list in archive page. But when I click terms menu then redirect following link: http://localhost/wordpress/chorui/project/html-3/ and show error message page not found.

<?php 
// Custom post and terms 
add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'deals',
        array(
            'labels' => array(
                'name' => __( 'Deals' ),
                'singular_name' => __( 'Deal' )
            ),
        'public' => true,
        'has_archive' => true,
        'hierarchical' => true    
        )
    );
}

register_taxonomy("project", array("deals"), array("hierarchical" => true, "label" => "Project Types", "singular_label" => "Project Type", "rewrite" => true));
?>


    <?php 
// archive-deals.php

get_header(); 

                                        wp_nav_menu(array(
                                            'theme_location' => 'top_menu',
                                            'container' => 'nav',
                                            'container_class' => 'top_menu',
                                            'fallback_cb' => false,
                                            'items_wrap' => '<ul>%3$s</ul>'
                                        ));

 /* Start the Loop */
 while ( have_posts() ) : the_post(); 

//This will return the content of the CPT archive

get_template_part( 'content', get_post_format());                   

 endwhile; 

  if ( function_exists('wp_bootstrap_pagination') ) {
    wp_bootstrap_pagination();
}

 get_footer(); 
?>
0

For the archive by the term, you should go with taxonomy template.

For you it will be taxonomy-project.php

When you work with custom post type , you should update the permalink structure when you make changes on templates, I mean register new post type or create new template file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.