Wordpress does not show Achive-custom-post.php

1

I have a custom post type called 'our-clients'. Create a document 'archive-our-clients.php' and when I place in the URL ' link ' it shows me the index.

plugin

function our_clients(){
  $labels = array(
    'name' => 'Our Clients',
    'singular_name' => 'Our Client'
    );

  $args = array(
    'labels' => $labels,
    'public' => true,
    'has_archive' => true,
    'publicly_queryable' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'supports' => array(
      'title',
      'thumbnail',
      'editor',
      'revisions'),
    'menu_position' => 4,
    'exclude_from_search' => true,
    'menu_name' => 'Our Clients',
    'menu_icon' => 'dashicons-star-filled',
    'can_export' => true
    );
  register_post_type('our-clients', $args);
}
add_action('init', 'our_clients'); 

archive-our-clients.php

<?php

    $args = array(
        'post_type'=>'our-clients',
        'posts_per_page' => -1,
        'post_status' => 'publish'
    );
    // The Query
    $the_query = new WP_Query( $args );

    if ( $the_query->have_posts() ) {
        while ( $the_query->have_posts() ) {
            $the_query->the_post();

            ?>

            <h2><?php echo the_title(); ?></h2> 

            <?php

            }

        wp_reset_postdata();

    }
    ?>

    
asked by MarisabelGC 27.07.2017 в 20:19
source

1 answer

0

I think what you need is to use flush_rewrite_rules() , so

function my_rewrite_flush() {
    flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_rewrite_flush' );

See this example . Another thing you can do is try to go to Settings > Permanent Links and there send the form again.

    
answered by 28.07.2017 в 22:17