0

Ok, the title does not help too much, so let me try and explain.

It's a Genesis-based website.

I created a CPT:

function cptui_register_my_cpts_livestreams() {

/**
 * Post Type: live streams.
 */

$labels = array(
    "name" => __( 'Live streams', '' ),
    "singular_name" => __( 'Live stream', '' ),
    "menu_name" => __( 'Live streams', '' ),
    "all_items" => __( 'All live streams', '' ),
    "add_new" => __( 'Add new live stream', '' ),
    "add_new_item" => __( 'Add new live stream', '' ),
    "edit_item" => __( 'Edit live stream', '' ),
    "view_item" => __( 'New live stream', '' ),
    "view_items" => __( 'View live streams', '' ),
    "search_items" => __( 'Search live streams', '' ),
    "archives" => __( 'Live streams', '' ),
);

$args = array(
    "label" => __( 'Live streams', '' ),
    "labels" => $labels,
    "description" => "",
    "public" => true,
    "publicly_queryable" => true,
    "show_ui" => true,
    "show_in_rest" => false,
    "rest_base" => "",
    "has_archive" => true,
    "show_in_menu" => true,
    "exclude_from_search" => false,
    "capability_type" => "post",
    "map_meta_cap" => true,
    "hierarchical" => false,
    "rewrite" => array( "slug" => "live-stream", "with_front" => true ),
    "query_var" => true,
    "supports" => array( "title", "thumbnail", "genesis-cpt-archives-settings", 'genesis-seo' ),
    'yarpp_support' => true,
);

register_post_type( "livestreams", $args );
}

add_action( 'init', 'cptui_register_my_cpts_livestreams' );

I also created a file: archive-livestreams.php

For some unknown reason when I go to https://inthebunch.co.za/live-stream/ it redirects me to the latest post created within that post type.

I cleared cache, re-saved permalinks etc... any advice?

  • What does archive-livestreams.php look like? – Jacob Peattie Feb 21 '19 at 8:00
  • Is it a redirect to a specific post url? If yes, what is the url? – Robbert Feb 21 '19 at 8:05
  • @JacobPeattie here is the code I currently have in there. <?php remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); add_action( 'genesis_entry_header', 'genesis_do_post_image', 8 ); genesis(); – labworxsa Feb 21 '19 at 8:31
  • @Robbert not a specific url, seems to always go to the latest post created in the cpt, in this case it is: inthebunch.co.za/live-stream/live-stream-uae-tour, previously it redirected to inthebunch.co.za/live-stream/live-stream-volta-ao-algarve – labworxsa Feb 21 '19 at 8:33
  • What if you empty your archive-livestreams.php? – Robbert Feb 21 '19 at 8:41
0

The URL of your archive is https://inthebunch.co.za/livestreams/.

Have a look at the docs for register_post_type, specifically, the description for the has_archive argument:

has_archive (boolean or string) (optional) Enables post type archives. Will use $post_type as archive slug by default. Default: false

In the case of your code, $post_type is livestreams:

register_post_type( "livestreams", $args );

If you want to change that value, you can supply a string for has_archive:

"has_archive" => "live-stream",

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.