Community Forums › Forums › Archived Forums › General Discussion › Desperate for help here: CPT archive redirects to single post
- This topic has 3 replies, 2 voices, and was last updated 5 years, 7 months ago by photoaddictsa.
-
AuthorPosts
-
February 22, 2019 at 1:07 am #489662photoaddictsaMember
Ok, the title does not help too much, so let me try and explain.
Running Genesis, but suspect that this is WordPress. Hoping someone here can help, tried other forums, no luck.
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
<?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();
For some unknown reason when I go to archive page: https://inthebunch.co.za/live-stream/ it redirects me to the latest post created within that post type, in this case: https://inthebunch.co.za/live-stream/live-stream-uae-tour/
Another post type I created in the exact same way as this one last year March, still works fine.
I cleared cache, re-saved permalinks etc... any advice?
February 22, 2019 at 2:53 am #489664andytcParticipantTry temporarily re-naming the archive.php from -
archive-livestreams.php
To -
archive-livestreams-bck.php
See if that makes any difference ?
Also check the permalink on that single post in the editor
February 22, 2019 at 3:14 am #489665photoaddictsaMemberOk, I managed to get it working on this url: https://inthebunch.co.za/live-streams/ by changing this line;
"has_archive" => "live-streams",
But now it looks like it's not using the custom archive page template, I named it:
archive-live-streams.php
February 22, 2019 at 3:21 am #489666photoaddictsaMemberScratch my last reply, i named the archive php wrong.
Thanks for the help 🙂
-
AuthorPosts
- The topic ‘Desperate for help here: CPT archive redirects to single post’ is closed to new replies.