magic-fields-team / Magic-Fields-2

Magic Fields 2.X
http://magicfields.org
GNU General Public License v2.0
124 stars 47 forks source link

Possible bug: 404 on post type URL rewrites #33

Closed EivindFS closed 8 years ago

EivindFS commented 13 years ago

Hey guys,

When I enable URL rewrite on my posts the permalinks throw 404s. When I disable it, they start working again.

I'm not sure if I'm doing something wrong or if there is a bug. I figured I'd report it anyway.

Cheers, Eivind

MarcusDalgren commented 13 years ago

This is one of the things I've fixed but not pushed in yet. In some cases you need to flush the rewrite rules in order for everything to work.

This is unfortunately not something WordPress does on its own.

hunk commented 13 years ago

Hi ElvindFS you can update and check again

EivindFS commented 13 years ago

Hi!

I just tried with the latest filebase and it still doesn't work.

Eivind

MarcusDalgren commented 13 years ago

Hi Eivind!

Did you save the post type again? The post type has to be saved for the rewrite flush to occur. If that doesn't work can you try going to the Permalinks page in the admin and saving that and see if that solves it?

Marcus

EivindFS commented 13 years ago

Yeah I saved the post type. It doesn't work. Also went to the permalink and saved. No change. (my permalink structure is /%category%/%postname% and category prefix is ".")

Please guide me to a place in the code where I can check that I'm indeed running a filebase with your fix in it.

Cheers, Eivind

MarcusDalgren commented 13 years ago

If none of that fixes the issue then you probably have conflicting rewrite rules somewhere. WordPress only allows one page type/taxonomy/etc per rule so if two different content types go for the same rule one of them gets the rule and the other one stops working.

Can you post the rewrite rules for the post type in question?

gleenk commented 13 years ago

I have this problem too...

MarcusDalgren commented 13 years ago

Then could you please post the rewrite rules you are using for your custom post types? Like I said in my last post if the rules are set up wrong then the problem isn't Magic Fields, it's the rules you set.

gleenk commented 13 years ago

It gives me 404 with every structure. I also tried to empty the rewrite_rules value field in db but nothing to do. In this moment I've set /%post_ID%/ and htaccess is:

BEGIN WordPress

RewriteEngine On RewriteBase /WPTEST/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /WPTEST/index.php [L]

END WordPress

but even with other combination it doesn't work for me...

jahberg commented 13 years ago

I can confirm this too...I am using /%category%/%postname%/ for permalinks and am getting the 404 errors on Custom post types and regular posts.

hunk commented 13 years ago

this works fine for me http://www.screenr.com/7YWs , have any special settings?

gleenk commented 13 years ago

No special settings for me, clean local installation with only MF installed. 1 Custom Post Type created and 1 Custom Taxonomy (with 3 terms) related to it.

MarcusDalgren commented 13 years ago

And everything worked before you turned on MF? Also does deactivating MF fix your problems?

gleenk commented 13 years ago

I haven't tried it before, but have never had problems before with this WP version, on the same machine. I can't deactivate MF now, I'm using it for a project, what will happen to everything? (is it possible to deactivate and re-activate it without burning everything? if yes, i'll make a try)

MarcusDalgren commented 13 years ago

Yes all your data will stay in the database so when you reactivate it again you get your post types back. We just want to make sure that it isn't something else.

gleenk commented 13 years ago

I've tried disabling MF. Permalink works correctly.

MarcusDalgren commented 13 years ago

Ok. So activate magic fields again and tell us what you set your rewrite rules to on your custom post types. IE go into the magic fields admin and edit your custom post types. Have you ticked the box that says Rewrite and if so, what have you written in the rewrite slug field?

Then do the same for your custom taxonomies and report back here. Ideally if you have set rewrite rules then list your post types and taxonomies and list the rule for each.

gleenk commented 13 years ago

Here the screenshots of my actual "not-working" config: http://imageshack.us/photo/my-images/190/mfbufstep1.jpg/ http://imageshack.us/photo/my-images/196/mfbufstep2.jpg/ http://imageshack.us/photo/my-images/577/mfbufstep3.jpg/

EivindFS commented 13 years ago

My htaccess file looks like this:

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

It's what I always use. You haven't pointed out yet what the changes to the filebase are, smurkas. If you can point me towards the place where I should look for a rewrite rules flush, I can at least double check that I'm using the correct code.

Cheers, Eivind

MarcusDalgren commented 13 years ago

The change was made by @hunk. The change should be in mf_posttype.php on line 555. You should have a function there called update_rewrite and the redirect on line 552 should be pointing to that function.

When I'm talking about the rewrite rules I'm not talking about your .htaccess file. That looks exactly the same for all standard WP installs. The issue is about the rewrite rules WordPress uses internally when figuring out what page/post/taxonomy/etc to load. It's fully possible to set those rules so that WordPress no longer can find pages for example. Basically it's one rule for each post type/taxonomy etc and if there's a conflict somewhere things get messy really fast.

gleenk commented 13 years ago

Has it been fixed? Now it works for me. I just uploaded new files and pushed "save permalinks" button 3-4 times :D

gnuget commented 13 years ago

@EivindFS

Can you confirm to this has been fixed?

gnuget commented 13 years ago

i'm going to close this bug for no activity feel free to re-open it if the bug not was fixed

kb6673 commented 13 years ago

I can still replicate this issue with the latest MagicFields available.

gleenk commented 13 years ago

Have you tried to press "save" on permalinks page 2 or 3 times? Try deleting htaccess, come back to permalinks and save 2 or 3 times. If not please write try to replicate the problem step by step for developers ;)

katrianna commented 12 years ago

Hi there,

I'm afraid I'm having custom post type rewrite/permalinks problems too.

If I set my Permalinks Custom Structure as follows:

/%category%/%postname%/

Only one of my Custom Post Types works correctly, the other 4 all throw up 404s. If I change the Permalink Structure to 'Default', they all work perfectly.

I've tried deleting the htaccess file, re-saving Permalinks a number of times and re-creating Post Types but no luck so far.

Any suggestions would be greatly appreciated.

Thanks Katri

katrianna commented 12 years ago

Sorry, I should've also mentioned that it makes no difference whether or not I tick the rewrite check box and enter a new slug on the individual Post Types. Cheers.

brunoatwork commented 12 years ago

Hey guys,

I was with the same problem. WP version 3.3.1 using last MF version too.

Suddenly all my new posts were retrieving 404 mitical error. I've been tweaking with all of the possible and findable fixes.

I've resolved my issue by inserting this structure /%category%/%year%/%postname%/ the only difference was the %year% snippet.

"...Now if you wonder why I had the %year% variable in the URL in there was because there have always been issues with WordPress permalink structures that don’t have a number in them, so adding the year solved that problem. "

Source: http://industrialmarketingadvisers.com/industrial-website-design_/2011/wordpress-3-1-problem-permalink-404-errors/

All best Guys!

blackboxadmin commented 10 years ago

I have the same problem using magic fields 2.2 and wordpress 3.7.1.

Just keep getting 404 errors on custom post types and sometimes all my other pages depending on what settings i use.

The only thing that works at the moment is setting the permalinks to default in the wp settings which isnt ideal.

flodar commented 10 years ago

I have the same problem!!

I updated to wordpress 3.7.1 and now there are 404 errors on custom post types.

MF 2.2 | Wordpress 3.7.1.

blackboxadmin commented 10 years ago

It took me ages to work out and after disabling every plugin but magic fields and doing multiple database wipes and fresh installs i tracked it down to having the Rewrite option ticked in one of my custom post types.

I had a custom post type for "services" and one for "team", services didnt have the rewrite option ticked and team did. I was concentrating on debugging the services so never noticed/thought that the problem would be with the team post type.

I finally turned off all rewrite options on all post types (the checkbox below archive slug on the post type options page) and the 404 errors stopped and all was working correctly.

It seems that the rewrite functionality of magic fields 2.2 is broken/has a bug in it. Ticking rewrite in one post type should not create 404 errors for other post types and pages.

With no rewrite options ticked all seems stable now and i can use the permalink structure /%category%/%postname%/ again. If however i re-enable the rewrite option in any post type i first get 404 errors on every page which i can fix by adding the line flush_rewrite_rules(false); to my functions.php file. (not a permanent fix as this seems to be quite a resource hungry function to run on every page load) then all pages work apart from custom post types which continue to have 404 errors.

Solution for now.

Dont use the rewrite option of magic fields 2.2.

manuelsofia commented 10 years ago

I still have the very same problem with version 2.2.1. There's no way to get a Rewrite Slug to work.

salvatorecapolupo commented 10 years ago

same problem here, see i.e. http://www.fidapasoveriamannelli.it/category/articoli/

hunk commented 8 years ago

I'm cleaning the issues if you still have this problem reopen the issue. thanks