Fresh install of Trellis, Bedrock, Sage, all latest stables as of post (June, 2016)
Created a basic CPT mu-plugin, we’ll call it stories
.
Using stock Sage, no custom archive nor single files.
Created a new Story entry.
visit /stories/story-one
Proceed to get 404s on both.
Double checked my CPT and markup. No issues.
Switched to 2015 theme and made a custom archive/single (the WP way) and it worked.
Removed files, returned to Sage.
And it works. (wat)
Create a new CPT, and again with the 404’s until disabling and reactivating.
cfx
June 4, 2016, 2:35pm
2
Do the CPTs 404 if you flush permalinks instead of deactivating/reactivating Sage?
Can you share a link to your plugin code?
Can confirm that simply flushing the permalinks fixes the issue with a fresh CPT,
Plugin code is everyday example
add_action( 'init', 'create_custom_cakes' );
function create_custom_cakes() {
register_post_type( 'cakes',
array(
'labels' => array(
'name' => __( 'Cakes' ),
'singular_name' => __( 'Cake' )
),
'public' => true,
'has_archive' => true,
)
);
}
cfx
June 4, 2016, 9:02pm
4
Spun up a fresh Trellis install here too and couldn’t reproduce it. Post your full plugin code please.
Interesting. I might dump this build and start a fresh as well.
what I posted was pretty much the whole codebase. I’ll include it all below.
<?php
/*
* Plugin Name: Cake CPT
* Version: 1.0
* Plugin URI:
* Description: Something
* Author: Cakes
* Author URI:
* @package WordPress
* @author Cake eater
* @since 1.0.0
*/
add_action( 'init', 'create_custom_cakes' );
function create_custom_cakes() {
register_post_type( 'cakes',
array(
'labels' => array(
'name' => __( 'Cakes' ),
'singular_name' => __( 'Cake' )
),
'public' => true,
'has_archive' => true,
)
);
}
cfx
June 4, 2016, 10:12pm
6
You might consider setting the rewrite
index in your registration call and also see here about plugin actions you might add , even though I didn’t need any with your example code. Btw, your permalink should appear right under the title; that’s the address I visit when I create a new post and it works just fine. Only mentioning that because your OP mentioned Stories but your code says Cakes.
Good tips. I’ll write up a better example and test. Stories was my original example not posted. Cakes was my other example.