Active page for custom post type

How is the archive page for a custom post type shown?

  • Dimitris
    • Support Star

    Hey there Tom,

    hope you're doing good and thanks for reaching us! :slight_smile:

    In order to activate archive pages of your custom post types, you should select "true" in "Has Archive" box of custom post type's settings page.

    For example, I did so for my "videos" custom post type in my localhost so I can now navigate to
    http://local.dev/videos/ for the archive page, and in
    http://local.dev/videos/my-video-page/ for my single video page.

    Hope that was some help, feel free to post back here if more assistance is required and please grant us with support access via WPMUDEV Dashboard plugin as described in following link, so we could have a better look inside!
    https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-4

    Warm regards,
    Dimitris

  • Adam Czajczyk
    • Support Gorilla

    Hello Tom!

    I had archive set to true, what should be set in the next two fields after that field. The name of my CPT is "letters"

    Also, if I have an archive page how do you set the number of posts shown?

    There's no need to change them, default settings should do the job. You will however want to create a custom post template file (see below).

    how do I limit the number of posts that are shown? Say, like three. Then with an arrow to advance to the next three.
    
    how do I add the CPT to the widget area?

    Custom posts use default template files of current theme if there's no "dedicated" custom post template file(s). WordPress is also using the default setting ("Settings -> Reading" -> "Blog pages show at most") for the number of posts that it's showing. You can change that setting but that will affect all posts on the site. If you wish to change it for custom posts only, the template file will be the way to go. It will also let you create a custom layout/design for that type of posts.

    To start with, please check this post on our blog:

    https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/

    That'd be the first step and the next one, once you got it working, would be to add a custom query that will limit the number of posts. You will want to add this line to your custom post template file before "The Loop":

    <?php query_posts( 'posts_per_page=3' ); ?>

    Take a look at this article please:

    https://codex.wordpress.org/The_Loop

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.