[Support request] How to make archive page for custom post type/tax

Home Forums Support How to make archive page for custom post type/tax

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1458164
    Eaydman

    I have a custompost type called Video, and added a custom tax called video-category.

    How do I make a archive page that works with my post type ?

    Im running All the newest beta of GeneratePress theme and Pro version.

    #1458226
    David
    Staff
    Customer Support

    Hi there,

    does your CPT include the 'has_archive' => true, argument ?

    #1458372
    Eaydman

    Ah no – It was false, but have change it to true now.
    On my page domain.com/video-category/tax-slug/ I still get “Nothing Found”

    This is how my settings looks link in the CPT.

    $args = array(
    ‘label’ => __( ‘video’, ‘xxxxx’ ),
    ‘description’ => __( ”, ‘xxxxx’ ),
    ‘labels’ => $labels,
    ‘menu_icon’ => ‘dashicons-screenoptions’,
    ‘supports’ => array(‘title’, ‘editor’, ‘revisions’, ‘thumbnail’, ‘author’, ‘custom-fields’, ),
    ‘taxonomies’ => array(),
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘menu_position’ => 5,
    ‘show_in_admin_bar’ => true,
    ‘show_in_nav_menus’ => true,
    ‘can_export’ => true,
    ‘has_archive’ => true,
    ‘hierarchical’ => false,
    ‘exclude_from_search’ => true,
    ‘show_in_rest’ => true,
    ‘publicly_queryable’ => true,
    ‘capability_type’ => ‘post’,
    ‘rewrite’ => array(‘slug’ => ‘video’),
    );

    What do I then do ?

    #1459133
    David
    Staff
    Customer Support

    You will need to create a copy of the themes archive.php template and place that in your child theme folder.

    The new archive will need to match the rewrite slug you have added to your template.
    eg.

    archive-video.php

    #1465125
    Eaydman

    I have copyed the “archive.php” and renamed it to “archive-video.php” in the child theme.

    But i still get the “Nothing Found”.
    Do i have to make some changes to the “archive-video.php” file ?

    #1465234
    Eaydman

    Or http://www.domain.com/video/ works fine, that show an archive page for all the post in that post-type.

    But I have a Custom-Post-Type (Video), where I have added a custom Tax named (video-category).

    So when I make a link to a Custom Tax. http://www.domain.com/video-category/cat-name that page says: “Nothing Found”

    #1465497
    David
    Staff
    Customer Support
    #1466640
    Eaydman

    I added the code:
    function add_custom_types_to_tax( $query ) {
    if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {

    // Get all your post types
    $post_types = get_post_types();

    $query->set( ‘post_type’, $post_types );
    return $query;
    }
    }
    add_filter( ‘pre_get_posts’, ‘add_custom_types_to_tax’ );

    But my CPT Custom Tax is still showing “Nothing Found” on http://www.domain.com/custom-tax/tax-name

    #1467735
    Tom
    Lead Developer
    Lead Developer

    This should all happen automatically without the need for functions or custom templates.

    Have you try re-saving your permalinks in “Settings > Permalinks”?

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