[Resolved] How do I create a CPT archive page that lists all my CPTS?

Home Forums Support How do I create a CPT archive page that lists all my CPTS?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #136663
    Pete

    How do I create a CPT archive page that lists all my CPTS like archive.php does for my categories?
    My CPT is called “profile” and so I copied the archive.php file into my child theme and renamed it archive-profile.php but it ain’t doin’ nutin’.

    WP says this…

    archive-{post_type}.php
    If your custom post type were ‘product’, and/or query_var = “product”, WordPress would look for archive-product.php to display the archive of posts.

    But when I go to mydomain.com/profile it doesn’t list them like mydomain.com/category lists my normal posts. Instead I get a 404.

    I’m guessing I’m missing something important!

    #136675
    Pete

    I think I have to add this piece of code… but i’m not sure where or how?

    $args = array( 'post_type' => 'profile', 'posts_per_page' => 10 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
      the_title();
      echo '<div class="entry-content">';
      the_content();
      echo '</div>';
    endwhile;
    #136677
    Pete

    All I want to do is have a separate archive.php and single.php for my custom post type so I can customise different from the normal posts.

    #136740
    Tom
    Lead Developer
    Lead Developer

    Naming it like that should work (archive-{post_type}.php).

    If going to the page is giving you a 404, rebuild your permalinks by going to “Settings > Permalinks” and clicking the save button.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.