Support » Plugin: News CPT » 4.0.1 update causes plugin to break existing ordinary posts with "News" category

  • It looks like the latest WordPress 4.0.1 caused this plugin to break existing Permalinks for Posts using the “News” category, resulting in a 404 not found.

    To be clear: it is not the new custom type “News” posts that your plugin adds that are breaking, but standard Posts using the same “News” category.

    We are using Pretty Permalink structure of: /%category%/%postname%/
    For example:
    http://www.domain.com/category/news is a Page that displays all the “News” category Posts in a list format, but clicking any of the links that look like:
    http://www.domain.com/news/some-post-name/

    Results in a 404 not found. I believe this used to work fine in WordPress 4.0

    When I disable this plugin, the “News” Posts can be clicked and seen again without resulting in a 404.

    Disabling and renabling this plugin and Re-saving permalinks did not fix this issue either.

    https://wordpress.org/plugins/news-cpt/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author vanjwilson

    (@vanjwilson)

    @hm-it,

    The following URL on my test site shows regular blog posts that are in a “News” category (added under Posts->Categories in the admin area):

    http://localhost:8888/category/news/

    … and clicking on a link in that list looks like this:

    http://localhost:8888/another-post/

    … without it adding any category string to the URL.

    My News CPT plugin creates its own URL path with /news/ at the root of all its URLs, without the /category/` part:

    http://localhost:8888/news/

    I tested this while my test site was still at 4.0.0, and after upgrading it to 4.0.1, and all the regular blog and ‘news’ links worked and didn’t run into each other (no 404s).

    I can think of four (4) troubleshooting things you can try, in order of increasing difficulty:

    (1) Change the name of the <em>News</em> category in your blog to something else. (My plugin is designed to section off “newsy” items from the blog entirely; so, having a <em>News category</em> may be redundant.) However, I can’t anticipate every possible use-case, so you may need that category to be that exact name.

    (2) Check Settings->Permalinks, in your admin area. 4.0.1 could have surfaced a bug that caused something in your set-up to change the “Custom Structure” of the permalinks to /%category%/%postname%/. When I changed to that on my test site, it broke my individual blog links in exactly the same way you described above. You’ll need to change the /%category% part to something else. I personally like to add /blog to the front of the permalink structure, but I work on sites with lots of static pages as well as blog posts, so adding “blog” makes the Google Analytics for blog posts easier to parse.

    (3) Check if you are using a plugin, like the one mentioned in <a href=”http://stackoverflow.com/questions/17798815/remove-category-tag-base-from-wordpress-url-without-a-plugin”>http://stackoverflow.com/questions/17798815/remove-category-tag-base-from-wordpress-url-without-a-plugin</a&gt;, that may be messing with the permalinks similar to what I described in (2) above. If that is now causing the conflicting URLs, you’ll need to see if that other plugin’s settings can help.

    (4) As a last resort, if you have to have that <em>News</em> category just as-is, and you want to change the URLs for my plugin, you can what WordPress uses for my URLs by changing some lines in my plugin files. (Changing the filename doesn’t affect URLs.) You would change the line in the custom post type definition array to use a slug different than /news. This is the section that would change:

    'rewrite' => array(
                    'slug' => 'news',
                    'with_front' => false
                    ),

    Changing this will not break any of your internal links or cause you to lose any of the News Items you already have–it’s merely cosmetic–but if other people have linked to your News Items, those links would break. You’d probably want to use a plugin like Quick Page/Post Redirect Plugin to bulk-add redirects to your News Items from their old names to the new names with your new ‘news’ slug.

    I hope one of these things helps.

    Thread Starter hm-it

    (@hm-it)

    Firstly, thank you for the detailed quick response and also taking your time to replicate the issue. It’s been busy this week so I apologize for not responding so quickly myself.

    In response to (2), I believe it was intentional on our part to change the permalink “Custom” structure to be “/%category%/%postname%/”
    (our category base in Permalink settings is blank). I, myself, am not the developer responsible for that decision but after reading up about it (based on my perceiving your assumption that we would not have done this on purpose) it appears this may not be ideal: http://ottopress.com/2010/category-in-permalinks-considered-harmful/

    Regarding (4) I attempted to make the code modification you suggested and it appears to work great at first glance. I do not think we are using any of the “News” custom post type pages that your plugin creates in a way those page URLs are being indexed by search engines, so this solution should be fine. We are currently only surfacing them on our homepage and the only link being displayed is links to external sites configured for those custom “news” post types your plugin added.

    Additionally, we have been using the above permalink /%category%/%postname%/ structure for more than a year so search engines have already indexed URLs with this structure for our ordinary “News” category posts.

    I know it may be much to ask, but would it be possible for you to make the “news” category slug configurable in your plugin in a future version? I will have to do more research and probably some convincing of the business owners concerning this permalink structure is not the way to go in the future.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘4.0.1 update causes plugin to break existing ordinary posts with "News" category’ is closed to new replies.