• Resolved boblodi

    (@boblodi)


    So I am at a loss.

    i just started working on a site which is using CPT UI v 1.1.1. Note – I didn’t build the site – so I am coming up to speed with whatever they did.

    And while I am familiar with CPTs, i am new to this plugin.

    there are only 3 CPTs in the site – news, press releases, and events.

    events is set up differently and is working fine.

    press releases – i can see them and click on them, but the archive links give me 404 errors.

    i can see the main news page, but, i get a 404 error trying to click through to the actual new item. also getting 404s on the archive links.

    there are no posts or pages called either of those things. there WAS a blog category called ‘news’ with a slug of ‘news’, but, even when i delete that and flush the WP and local cache, I still have the problem – can’t read the news.

    the new page is at http://us.sios.com/news/

    as far as I can tell, news, PR and events are set up the same way, one works, the other does not.

    $labels = array(
    “name” => “News Items”,
    “singular_name” => “News Item”,
    );

    $args = array(
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “show_ui” => true,
    “has_archive” => true,
    “show_in_menu” => true,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => false,
    “rewrite” => array( “slug” => “news”, “with_front” => true ),
    “query_var” => true,

    “supports” => array( “title”, “editor”, “excerpt” ),
    );
    register_post_type( “news”, $args );

    $labels = array(
    “name” => “Press Releases”,
    “singular_name” => “Press Release”,
    “menu_name” => “Press Releases”,
    );

    $args = array(
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “show_ui” => true,
    “has_archive” => true,
    “show_in_menu” => true,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => false,
    “rewrite” => array( “slug” => “press-releases”, “with_front” => true ),
    “query_var” => true,

    “supports” => array( “title”, “editor”, “excerpt” ),
    );
    register_post_type( “press-releases”, $args );

    i’ve reset permalinks more times than i can count. i’ve also moved the site to a staging instance which has an even weirder problem with some crazy redirect, but also the 404 errors on news items. Permalinks are set to month and name.

    i’ve read many threads and looked on the forum and tried whatever I could – and nothing so far is working.

    if i change the slug – do I lose all the posts? thats the last idea i have but I don’t want to blow it all up.

    Any ideas are helpful.

    https://ww.wp.xz.cn/plugins/custom-post-type-ui/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Just some quick notes to start off.

    I’m curious if, for some reason, the with_front being true is part of the issue, and wonder if setting those to false would help.

    If you change the slug, you technically register a new post type in our settings with a different slug, but there is the option to migrate between the slugs as well. Even if you don’t check that, the actual post content never gets deleted by us, and remains in the database. Re-registering a post type that matches the database values picks them up again.

    Thread Starter boblodi

    (@boblodi)

    I *think* i tried that but I can try it again.

    stay tuned…

    Thread Starter boblodi

    (@boblodi)

    No luck with with_front set to false. I also tried opening and closing the first news item. and resetting permalinks/clearing cache again. I know there was weirdness with this site before I started working on it. like all the news was in the blog area, then it got moved… but so were the press and events…

    add_action( ‘init’, ‘cptui_register_my_cpts’ );
    function cptui_register_my_cpts() {
    $labels = array(
    “name” => “News Items”,
    “singular_name” => “News Item”,
    );

    $args = array(
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “show_ui” => true,
    “has_archive” => true,
    “show_in_menu” => true,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => false,
    “rewrite” => array( “slug” => “news”, “with_front” => false ),
    “query_var” => true,

    “supports” => array( “title”, “editor”, “excerpt” ),
    );
    register_post_type( “news”, $args );

    $labels = array(
    “name” => “Events”,
    “singular_name” => “Event”,
    );

    $args = array(
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “show_ui” => true,
    “has_archive” => true,
    “show_in_menu” => true,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => false,
    “rewrite” => array( “slug” => “events”, “with_front” => true ),
    “query_var” => true,

    “supports” => array( “title”, “editor”, “excerpt” ),
    );
    register_post_type( “events”, $args );

    $labels = array(
    “name” => “Press Releases”,
    “singular_name” => “Press Release”,
    “menu_name” => “Press Releases”,
    );

    $args = array(
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “show_ui” => true,
    “has_archive” => true,
    “show_in_menu” => true,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => false,
    “rewrite” => array( “slug” => “press-releases”, “with_front” => true ),
    “query_var” => true,

    “supports” => array( “title”, “editor”, “excerpt” ),
    );
    register_post_type( “press-releases”, $args );

    // End of cptui_register_my_cpts()
    }

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    It’s going to be something specific with your site and probably the rewrite rules. I just copy/pasted your output from the last reply into my functions.php and posts work fine with it as is.

    Another thing I’m curious about is if, at least for the news part, it’s still thinking of it as a term archive, but we’d need to see the request being made to determine that.

    Thread Starter boblodi

    (@boblodi)

    How do i see what the request is? should i add in that command to flush the rewrite rules do you think? I am sure it’s something with the site, but i havent found anything yet. Thanks for the help – on a Sunday even – I appreciate it.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    How much of a developer type are you? Are you more of an end user? or are you comfy with PHP editing, for example?

    Thread Starter boblodi

    (@boblodi)

    Bring on the PHP editing – i am fine with that.

    FWIW – i have tried this morning deleting any categories from the staging database via phpmyadmin that had ‘news’ in them. so far it hasnt helped. i am hoping it’s cached.

    Thread Starter boblodi

    (@boblodi)

    well, something is up with the site for sure. Weird things happen when I mess with the settings on the staging site – it starts appending a post to the main /news link. I am not finding anything in all the 301 redirects or functions.php or the database that explain it to me.

    i did try creating a new CPT and that worked fine.

    so it has something to do with ‘news’. though that doesn’t explain why the archive links such as http://us.sios.com/press-releases/2015/03/ also get 404s.

    My best guess is to change the ‘news’ cpt to something else. is there a way i can do that and then re-import the posts or something? there are 132 or so news posts – i’d rather not do that manually if there is a shortcut.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I recommend https://ww.wp.xz.cn/plugins/query-monitor/ for quite a lot of debugging of things, part of the data displayed will be the request being made.

    Specifically, the “Request” spot in the admin bar menu that shows up. It’ll display something like the following: https://cloudup.com/cTtic0VVBgS

    That said, if you’re on CPTUI 1.1.x and definitely wanting to rename, there should be a checkbox available for migrating posts when renaming the registered post type with our plugin. It’ll make a query for the posts of the old post type, and update them all with the new one. Check your CPTUI post type editor screen.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Nothing gets auto-deleted when you rename post type slugs, for the record, they just lose the association with the posts in the wp_posts table. Insanely easy to get them “back” once you re-use the same post type slug.

    Thread Starter boblodi

    (@boblodi)

    Thanks. ill check out query monitor and see what that says. one other thing ive tried is deleting all the rewrite rules i found in the database in the wp-options table. that didn’t fix it either…

    Thread Starter boblodi

    (@boblodi)

    Not sure if these mean anything to you – the only difference I see is the queried object line at the bottom of the PR one. to recap – press releases work, news does not yet.

    news query screen shot

    press query screen shot

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Do they work if you have no permalink settings set?

    Thread Starter boblodi

    (@boblodi)

    ive tried custom, i’ve tried post-name, i tried default. that didnt work.

    i just tried changing the slug and migrating the posts – that DID work. so I may just go with that…

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    If the default aka no permalinks/just URL params didn’t work, then there’s something more going on with this and it’s not permalink related.

Viewing 15 replies - 1 through 15 (of 18 total)

The topic ‘404 errors on on only some CPTs’ is closed to new replies.