• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Desperate for help here: CPT archive redirects to single post

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Desperate for help here: CPT archive redirects to single post

This topic is: resolved

Tagged: CPT, redirect

  • This topic has 3 replies, 2 voices, and was last updated 4 years, 1 month ago by photoaddictsa.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • February 22, 2019 at 1:07 am #489662
    photoaddictsa
    Member

    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 #489664
    andytc
    Participant

    Try 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 #489665
    photoaddictsa
    Member

    Ok, 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 #489666
    photoaddictsa
    Member

    Scratch my last reply, i named the archive php wrong.

    Thanks for the help 🙂

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Desperate for help here: CPT archive redirects to single post’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble