Title: Permalinks causing 404 errors on custom post type
Last modified: August 21, 2016

---

# Permalinks causing 404 errors on custom post type

 *  Resolved [pixelkicks](https://wordpress.org/support/users/pixelkicks/)
 * (@pixelkicks)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/)
 * Hi,
 * I have created the following custom post type:
 * `events`
 * Permalinks are set to:
 * `/%postname%/`
 * A sample URL for one of the created events is:
 * `http://www.domain.com/events/business-after-5-with-qantas-in-the-frame/`
 * Yet this gives a 404 when we try it. What do we have to do to get the permalinks
   working? We’ve already tried re-saving the permalinks a few times.
 * Chris.
 * [http://wordpress.org/plugins/custom-post-type-ui/](http://wordpress.org/plugins/custom-post-type-ui/)

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

1 [2](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/page/2/?output_format=md)

 *  Thread Starter [pixelkicks](https://wordpress.org/support/users/pixelkicks/)
 * (@pixelkicks)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081389)
 * Further to this, the links don’t even work with standard permalinks.
 * Is there something I’m missing? I’ve set any taxonomies but I assumed I didn’t
   need to?
 * Chris.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081412)
 * So the links to your CPT posts aren’t working even without permalinks?
 * Nope, taxonomies aren’t a requirement for it to work.
 * Could you pastebin the settings you used for your CPT? I’ll see if it gives me
   the same issues at all. You’ll be able to get them in a pasteable format via 
   the “Get Code” link when you go to edit the CPT. Ignore the “broken” quotes aspect,
   that’s fixed in the next, pending, release, and this isn’t what does the actual
   registering.
 *  Thread Starter [pixelkicks](https://wordpress.org/support/users/pixelkicks/)
 * (@pixelkicks)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081414)
 * Hi Michael,
 * Thats right. I’ve spent the last two hours struggling to get any links to work
   at all. Normal posts and pages work fine with any permalink structure in place
   though.
 * This is a dev site we’re working on and its hosted on a Windows server. This 
   wouldn’t make a different for the rewrite rules would it?
 * Custom Post Type settings:
    [http://pastebin.com/dr9UGrwN](http://pastebin.com/dr9UGrwN)(
   incidentally they give an error if I try and paste into functions.php manually)
 * Web.config:
 *     ```
       <rule name="wordpress" patternSyntax="Wildcard">
       	<match url="*"/>
       		<conditions>
       			<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
       			<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
       		</conditions>
       	<action type="Rewrite" url="index.php"/>
       </rule>
       ```
   
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081456)
 * Actually, I think it would have an influence on rewrites. Linux hosting and Windows
   hosting aren’t the same with this topic. That said, I’m also out of the running
   for good help, as I have never debugged IIS issues with rewrites :(. I’m wondering
   if that’s the primary area of issue.
 * Yeah, you’d need to review the pastebin code before pasting into functions.php
   and hitting save, make sure it’s done right. Like I said in my first reply, it’s
   pending fixed in the next release. Hopefully soon.
 *  Thread Starter [pixelkicks](https://wordpress.org/support/users/pixelkicks/)
 * (@pixelkicks)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081471)
 * Hmm that makes things awkward!
 * Should the permalinks work “straight out of the box” generally then? Do you have
   an example of a .htaccess file for my sceneario above I could use to compare?
   Might help with any debugging.
 *  Thread Starter [pixelkicks](https://wordpress.org/support/users/pixelkicks/)
 * (@pixelkicks)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081472)
 * Ok, this is getting strange now. I’ve just tried the following code directly 
   in my functions.php, and it works perfectly now!
 * [http://pastebin.com/2ipGnAx6](http://pastebin.com/2ipGnAx6)
 * The codes is what I took using “Get Code”, but I had to amend a few extra unneeded
   apostrophes. I resaved the permalinks setting and it worked. The web.config file
   remains unchanged though.
 * Why would putting the code directly in functions.php cause it to work? Surely
   its exactly the same?
 * Any ideas?
 * Chris.
 *  Thread Starter [pixelkicks](https://wordpress.org/support/users/pixelkicks/)
 * (@pixelkicks)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081473)
 * Just for extra details, I commented out the code, resaved the permalinks settings
   and straight away the link gives a 404.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081474)
 * One would think so. Here’s an example from a linux hosted version, with one of
   the default options available.
 *     ```
       # BEGIN WordPress
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule . /index.php [L]
       # END WordPress
       ```
   
 *  [ibecker](https://wordpress.org/support/users/ibecker/)
 * (@ibecker)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081650)
 * I was having the same problem and it was driving me crazy for 2 weeks. I was 
   able to fix it by going to the Advanced Options on the post type I was trying
   to view, and change “Has Archive” to “True” and boom, they worked!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081653)
 * thanks for the feedback ibecker. Hopefully that helps pixelkicks. Now to have
   me remember that that needs to true for archives to work. 😀
 *  [ucarman2002](https://wordpress.org/support/users/ucarman2002/)
 * (@ucarman2002)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081654)
 * hello
    i am having the same problem. sorry no such page error when previewing
   changes to published post. i have been reading forums for a week and have tried
   all the recommended fixes except adding flush rewrite rules. not sure where to
   place this code. any help with this?
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081655)
 * ucarman2002, just visiting the permalinks settings page should flush you rewrite
   rules.
 *  Thread Starter [pixelkicks](https://wordpress.org/support/users/pixelkicks/)
 * (@pixelkicks)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081656)
 * That sounds positive ibecker, and I’ll give it a try in future.
 * As it was I had to stop using the plug-in, instead using some code I found on
   another website to create the custom post types. Got it working perfectly in 
   the end.
 * Maybe it might have just been the “Has Archive” settting all along.
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081657)
 * No worries here. I’d rather you get what you need done than if it involves our
   plugin 🙂
 *  [ucarman2002](https://wordpress.org/support/users/ucarman2002/)
 * (@ucarman2002)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/#post-4081662)
 * hello
    visiting the permalinks page does not solve problem. preview changes after
   post is published still produces 404 error. page not found. have tried in different
   themes. have tried disabling all plugins,except custom post type UI. I believe
   the problem was caused by having posts with the same name as the custom post 
   type. I deleted all of those and tried all of the above again. no luck. any ideas?
   thanks

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

1 [2](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/page/2/?output_format=md)

The topic ‘Permalinks causing 404 errors on custom post type’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

## Tags

 * [permalinks](https://wordpress.org/support/topic-tag/permalinks/)

 * 24 replies
 * 6 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/permalinks-causing-404-errors-on-custom-post-type/page/2/#post-4081729)
 * Status: resolved