• Resolved pixelkicks

    (@pixelkicks)


    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:

    https://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.

    https://www.ads-software.com/plugins/custom-post-type-ui/

Viewing 15 replies - 1 through 15 (of 24 total)
  • Thread Starter pixelkicks

    (@pixelkicks)

    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

    (@tw2113)

    The BenchPresser

    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

    (@pixelkicks)

    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:
    https://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

    (@tw2113)

    The BenchPresser

    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

    (@pixelkicks)

    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

    (@pixelkicks)

    Ok, this is getting strange now. I’ve just tried the following code directly in my functions.php, and it works perfectly now!

    https://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

    (@pixelkicks)

    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

    (@tw2113)

    The BenchPresser

    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

    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

    (@tw2113)

    The BenchPresser

    thanks for the feedback ibecker. Hopefully that helps pixelkicks. Now to have me remember that that needs to true for archives to work. ??

    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

    (@tw2113)

    The BenchPresser

    ucarman2002, just visiting the permalinks settings page should flush you rewrite rules.

    Thread Starter pixelkicks

    (@pixelkicks)

    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

    (@tw2113)

    The BenchPresser

    No worries here. I’d rather you get what you need done than if it involves our plugin ??

    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)
  • The topic ‘Permalinks causing 404 errors on custom post type’ is closed to new replies.