Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

UPDATE! multisite 404 caused by register_post/tax... WordPress

  • SOLVED

<strong>----UPDATE---</strong>

After painstaking process of elimination via dropping databases and re uploading a 100 times whilst removing functions one by one, I think I found the f**ker causing the problem.


For you newbies It is a very strange issue with my multisite where I get 404 on pages.


My multisite runs absolutely fine, until randomly (possibly because of updating a setting), I get 404 errors on all pages.

I can force create the 404 error by updating the reading settings to a static page...

[[LINK href="http://i.imgur.com/RRqBU1m.png"]]http://i.imgur.com/RRqBU1m.png[[/LINK]]


I can choose any template, or then try to revert "Your Latest Posts" on this page, and the 404 occurs.

If you switch to another theme, the 404 error is carried over, but weirdly you just get the home page for every single page - so the problem must be in the db.

The only way I get rid of the 404 error is by reseting my database to a previous version before the 404 error has occurred


This is how i found what I think is causing it...


<strong>1.</strong> I deleted my functions.php contents. And updated my reading settings. The site works fine! No 404 error.

<strong>2.</strong> I re added my functions.php contents. Still no error.

<strong>3. </strong> I updated my reading settings to force create the error - and yes, I got the 404.

<strong>4. </strong> I reset my database, and 404 has gone.

<strong>5. </strong> I deleted all my function contents, added them one by one, refreshing my website each time. I did NOT get a 404, site works fine.

<strong>6. </strong> I deleted all my functions again, added them one by one, but each time I added one, I updated my reading settings, and when I add the function below, I got the 404, see below what is causing it...



// REGISTER POST TYPE INDIVIDUALS
register_post_type(
'individual',array(
'label' => 'Individuals',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array(
'slug' => ''
),
'query_var' => true,
'exclude_from_search' => false,
'supports' => array(
'title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes'
),
'taxonomies' => array(
'type'
),
'labels' => array (
'name' => 'Individuals',
'singular_name' => 'Individual',
'menu_name' => 'Individuals',
'add_new' => 'Add Individual',
'add_new_item' => 'Add New Individual',
'edit' => 'Edit',
'edit_item' => 'Edit Individual',
'new_item' => 'New Individual',
'view' => 'View Individual',
'view_item' => 'View Individual',
'search_items' => 'Search Individuals',
'not_found' => 'No Individuals Found',
'not_found_in_trash' => 'No Individuals Found in Trash',
'parent' => 'Parent Individual'
),
'menu_icon' => get_bloginfo('template_url').'/images/menu_icon.png'
)
);
register_taxonomy('individual-group',array (
0 => 'individual',
),array( 'hierarchical' => true, 'label' => 'Group Number','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Group Number') );
register_taxonomy('individual-role',array (
0 => 'individual',
),array( 'hierarchical' => true, 'label' => 'Role','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Role') );
register_taxonomy('individual-territory',array (
0 => 'individual',
),array( 'hierarchical' => true, 'label' => 'Territory','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Territory') );



How can this be fixed, need urgent help please?

Thanks


<strong>----ORIGINAL QUESTION---</strong>


Hello,

I am having a problem using a Page as a static front page on my multisite.

On my multi site ID 1 I have set up the settings below...

[[LINK href="http://i.imgur.com/RRqBU1m.png"]]http://i.imgur.com/RRqBU1m.png[[/LINK]]


So my home page is using the welcome page.

The welcome page works, but all my other pages then return 404.

If I turn this option off then the site is back to normal.


With problem still running, I've deleted all plugins, emptied my entire functions php, deleted most of the contents of my theme, and the problem does not go away.



RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]


My ,htaccess is definitely being read too


Can any one help.
Thanks



<strong>----PLEASE READ UPDATE AT TOP ---</strong>

Answers (5)

2013-02-15

Francisco Javier Carazo Gil answers:

Look this thread: http://wordpress.org/support/topic/adding-static-sites-to-my-multisite-network


Josh Cranwell comments:

Hi Francisco,

Its not a static site, its a just page.

I just want to display a page on the home page, instead of latest posts.

In Settings > Reading

Please see screenshot [[LINK href="http://i.imgur.com/RRqBU1m.png"]]http://i.imgur.com/RRqBU1m.png[[/LINK]]


Francisco Javier Carazo Gil comments:

Ah ok, have you tried to set WP_DEBUG to true and see if there any error or warning?


Josh Cranwell comments:

I got 2 notices about some get_blog_list being depreciated.

I removed this and it still show 404.

2013-02-15

Plugarized answers:

Try moving the .htacess file to the public_html folder or copy it, most of the times is due to misconfiguration of the htacess file and also choose default permalink and then custom %postname%


Josh Cranwell comments:

Where is this folder?

This is my current setting and my .htaccess is the default multisite setup taken from codex

[[LINK href="http://i.imgur.com/ORmyf5Q.png"]]http://i.imgur.com/ORmyf5Q.png
[[/LINK]]


Plugarized comments:

Well the other would be to check for allow overrides in your httpd.conf file which is apache configuration file

< Directory />
AllowOverride All
</Directory>


Plugarized comments:

If you cant check the apache config, then have you configured properly your wp-config.php


/* Multisite */
define('WP_ALLOW_MULTISITE', true);

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
$base = '/';
define('DOMAIN_CURRENT_SITE', 'www.mysite.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);



Josh Cranwell comments:

By adding $base = '/'; it did not change anything :-(


Josh Cranwell comments:

< Directory />
AllowOverride All
</Directory>

This did not work..


Plugarized comments:

What about the structure of your network is it subdomain or subdirectory install?


Josh Cranwell comments:

subdomain install.


Plugarized comments:

Have you correctly followed the following. go to /tools/network/ and perform those procedures

http://codex.wordpress.org/File:tools-network-created.png


Plugarized comments:

btw is your host godaddy or hostgator?

godaddy usually caches the htacess file and refreshes every hour or so, as for hostgator, they usually dont mind looking at the configurations.


According to a source, with a similar issue to yours and if your on godaddy, the permalink problem was fixed by going to godaddy control panel, going to setttings, 404 error handling, and changed the default “godaddy’s 404 error page” to “home page.

Src. Wordpress forums


Plugarized comments:

The changes usually take 30 mins to take effect


Josh Cranwell comments:

Have you got this source? I don't understand as the .htaccess does not change for this?


Plugarized comments:

Okay this is my last attempt Zzzz I need to sleep. please add in .htacess "Options +FollowSymLinks" without quotes, or copy and paste the following code into your .htacess

# BEGIN WordPress
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress


I hope you get the problem fixed.


Josh Cranwell comments:

thanks for your efforts...

Though I get Internal Server Error


Plugarized comments:

So did you resolve this? I think is time to let someone have a closer look at your website, perhaps it has something to do with your host

2013-02-15

Arnav Joy answers:

try resetting permalink once again after setting reading to static front page


Josh Cranwell comments:

Just tried that, still 404 weirdly :/


Arnav Joy comments:

for these two lines

RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]


repalce them with


RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]


Arnav Joy comments:

one more thing did you checked posts , are they also showing 404


Josh Cranwell comments:

Posts are working fine :-)

Your update for the htaccess did not change anything :-(


http://mysite.com/2013/02/test/ - test post works fine

http://mysite.com/individual/test - test post type called individual, works fine

http://mysite.com/test/ - test page <strong>shows 404</strong>


Arnav Joy comments:

can you show wp-config.php file


Josh Cranwell comments:

Here it is...

https://gist.github.com/jcranny/4960081


Josh Cranwell comments:

Its not my theme for definite.

I just installed the twentytwelve theme and its happening on here too...


Arnav Joy comments:

do one thing change slug of any page and then check it


Arnav Joy comments:

try to set false multisite install and then check if it happens on normal install of wp also

so in wp-config.php set these two variables to false

define('WP_ALLOW_MULTISITE', false);
define('MULTISITE', false);

if possible then please take back up first


Josh Cranwell comments:

Took backup.

Did what you said...

define('WP_ALLOW_MULTISITE', false);
define('MULTISITE', false);

Could not login, could not see front page. Should I activate twentytwelve theme before doing this? As my theme doesnt like running as normal site.


Josh Cranwell comments:

Was just a grey screen


Arnav Joy comments:

first activate twentyelven then alow do things


Josh Cranwell comments:

twentyelven running, all my pages are showing home page (not 404 this time)

Posts work fine.

Checked htaccess and it is still this?



RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]



# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]



Josh Cranwell comments:

Just updated permalink settings and htaccess now updated.

Twenty twelve theme works OK with welcome template -

http://i.imgur.com/GsO9xDa.png


Josh Cranwell comments:

OK I just set it up as network again with Twenty twelve theme - but all pages use welcome page.

But it works fine as a non-multishite install.

Have you got a test multi site running on your server?


Josh Cranwell comments:

Hi Arnav,

I have done a precise walk through on how to create my multisite error in 10 steps.

[[LINK href="http://motocomdigital.co.uk/temp/wpquestions-8032.zip"]]http://motocomdigital.co.uk/temp/wpquestions-8032.zip[[/LINK]]


Any urgent help will be rewarded. Thanks

Josh

2013-02-15

Kiet Luong answers:

Hi, please try this.

[[LINK href="http://custhemes.com/article/wordpress-multisite-how-to-use-postname-permalink/"]]http://custhemes.com/article/wordpress-multisite-how-to-use-postname-permalink/[[/LINK]]

hope this help. :)


Josh Cranwell comments:

Hi

My permalink structure is still as default. And my problem still occurs.

If I change this setting back to default... [[LINK href="http://i.imgur.com/RRqBU1m.png"]]http://i.imgur.com/RRqBU1m.png[[/LINK]]

Then it works fine.

Its only when I choose my home page to use another page.







Kiet Luong comments:

Can not see this image,
can I see your site ?
I thought problem was in your theme framework.


Kiet Luong comments:

why not try with that post, may it help you !


Josh Cranwell comments:

No the problem is not in my theme frame work, happens with Twenty twelve


Kiet Luong comments:

did you try to run that theme on another demo site, to check if that still same problem or not !


Josh Cranwell comments:

I will do now, gime 2 sec


Kiet Luong comments:

still error ?


Josh Cranwell comments:

Yes still error - have you seen my question update...


Kiet Luong comments:

Please try to replace your functions with this.


// REGISTER POST TYPE INDIVIDUALS

register_post_type(

'individual',array(

'label' => 'Individuals',

'description' => '',

'public' => true,

'show_ui' => true,

'show_in_menu' => true,

'capability_type' => 'post',

'hierarchical' => false,

'query_var' => true,

'exclude_from_search' => false,

'supports' => array(

'title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes'

),

'taxonomies' => array(''),

'labels' => array (

'name' => 'Individuals',

'singular_name' => 'Individual',

'menu_name' => 'Individuals',

'add_new' => 'Add Individual',

'add_new_item' => 'Add New Individual',

'edit' => 'Edit',

'edit_item' => 'Edit Individual',

'new_item' => 'New Individual',

'view' => 'View Individual',

'view_item' => 'View Individual',

'search_items' => 'Search Individuals',

'not_found' => 'No Individuals Found',

'not_found_in_trash' => 'No Individuals Found in Trash',

'parent' => 'Parent Individual'

),

'menu_icon' => get_bloginfo('template_url').'/images/menu_icon.png'

)

);

register_taxonomy('individual-group',array (

0 => 'individual',

),array( 'hierarchical' => true, 'label' => 'Group Number','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Group Number') );

register_taxonomy('individual-role',array (

0 => 'individual',

),array( 'hierarchical' => true, 'label' => 'Role','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Role') );

register_taxonomy('individual-territory',array (

0 => 'individual',

),array( 'hierarchical' => true, 'label' => 'Territory','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Territory') );


Josh Cranwell comments:

I just reset my database,

Change to your answer - and its still broken.

Just to update you, I tried my original code on a test site, and I could not get the same 404 error.

I then uploaded posts to this custom post type via [[LINK href="http://wordpress.org/extend/plugins/csv-importer/"]]CSV Importer[[/LINK]] and it I then got the error once I updated my reading settings.


Kiet Luong comments:

Try this :


/ REGISTER POST TYPE INDIVIDUALS

register_post_type(

'individual',array(

'label' => 'Individuals',

'description' => '',

'public' => true,

'show_ui' => true,

'show_in_menu' => true,

'capability_type' => 'post',

'hierarchical' => false,

'rewrite' => array(

'slug' => ''

),

'query_var' => true,

'exclude_from_search' => false,

'supports' => array(

'title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes'

),

'taxonomies' => array(''),

'labels' => array (

'name' => 'Individuals',

'singular_name' => 'Individual',

'menu_name' => 'Individuals',

'add_new' => 'Add Individual',

'add_new_item' => 'Add New Individual',

'edit' => 'Edit',

'edit_item' => 'Edit Individual',

'new_item' => 'New Individual',

'view' => 'View Individual',

'view_item' => 'View Individual',

'search_items' => 'Search Individuals',

'not_found' => 'No Individuals Found',

'not_found_in_trash' => 'No Individuals Found in Trash',

'parent' => 'Parent Individual'

),

'menu_icon' => get_bloginfo('template_url').'/images/menu_icon.png'

)

);

register_taxonomy('individual-group',array (

0 => 'individual',

),array( 'hierarchical' => true, 'label' => 'Group Number','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Group Number') );

register_taxonomy('individual-role',array (

0 => 'individual',

),array( 'hierarchical' => true, 'label' => 'Role','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Role') );

register_taxonomy('individual-territory',array (

0 => 'individual',

),array( 'hierarchical' => true, 'label' => 'Territory','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => ''),'singular_label' => 'Territory') );



Josh Cranwell comments:

nOpe this does not work

Have you recreated my error?

I can walk you through it on skype from a fresh network install with sub domains


Kiet Luong comments:

You said, you've used CSV Importer plugins so what is the name of custom post type that you have exported the posts ?


Josh Cranwell comments:

Not exported, imported, I am going to send you a zip with step by step instructions on how to recreate my error.

You will see


Kiet Luong comments:

do you use skype or gtalk ?


Josh Cranwell comments:

Hi Arnav,

I have done a precise walk through on how to create my multisite error in 10 steps.

[[LINK href="http://motocomdigital.co.uk/temp/wpquestions-8032.zip"]]http://motocomdigital.co.uk/temp/wpquestions-8032.zip[[/LINK]]


Any urgent help will be rewarded. Thanks

Josh


Josh Cranwell comments:

Hi Arnav,

I have done a precise walk through on how to create my multisite error in 10 steps.

[[LINK href="http://motocomdigital.co.uk/temp/wpquestions-8032.zip"]]http://motocomdigital.co.uk/temp/wpquestions-8032.zip[[/LINK]]


Any urgent help will be rewarded. Thanks

Josh


Josh Cranwell comments:

Hi Kiet, (whoops sorry very tired - yes I do use skype)

I have done a precise walk through on how to create my multisite error in 10 steps.

[[LINK href="http://motocomdigital.co.uk/temp/wpquestions-8032.zip"]]http://motocomdigital.co.uk/temp/wpquestions-8032.zip[[/LINK]]


Any urgent help will be rewarded. Thanks

Josh

2013-02-17

Christianto answers:

Hi Josh,

Please check with this [[LINK href="http://wordpress.org/extend/plugins/rewrite-rules-inspector/"]]rewrite rules plugin inspector[[/LINK]],
You can check if any new rewrite rules added after adding those CPT.

Did you use subdomains or subdirectory for this site?
Maybe you could try by adding slug?
'rewrite' => array('slug' => 'myslug')


Josh Cranwell comments:

OK I will tell you result if plugin

Gimme 5


And I am using subdomains

'rewrite' => array('slug' => 'myslug')

What is myslug meant to be?


Thanks


Josh Cranwell comments:

It says some rewrite rules might be missing - try flusing.

I dont really know what I'm looking for :/


Josh Cranwell comments:

I just tried flusing but now got 404 on every thing :/


Josh Cranwell comments:

I don't understand what I need to do with this?

I reset db again and I just tried updating but 404 when I ho

'rewrite' => array(
'slug' => 'individual'
),


AAAhhh


Christianto comments:

Don't flush it, I don't think the plugin support rewrite flush for multiple blog (network)..
Are you able to check new added rules with that inspector?

or if you set 'rewrite' to false so there will be no rules added, is it working?


Josh Cranwell comments:

Hi Christianto,

I have done a precise walk through on how to create my multisite error in 10 steps.

[[LINK href="http://motocomdigital.co.uk/temp/wpquestions-8032.zip"]]http://motocomdigital.co.uk/temp/wpquestions-8032.zip[[/LINK]]


Any urgent help will be rewarded. Thanks

Josh


Josh Cranwell comments:

How do you set rewrite to false?

The 'source' on all my individual are missing - is that what is causing the issue?

How do I fix missing rewrites?


Christianto comments:

on your register post type/taxonomy function argument you can pass
'rewrite' => false
instead of
'rewrite' => array(
'slug' => ''
),

you need to reset database before register CPT/taxonomy with rewrite set to false, because rewrite rules saved on database.

I couldn't said that what happen in your front page was because your custom post type rewrite rules,
since front page isn't CPT, but we can check if rewrite rules causing this..


Josh Cranwell comments:

Yeah that is the problem. Yeah all is fixed on the multisite front! Now to finish the site in 5 hours. Thanks for your great help. And thanks for your email the other day, I have been flat out on this project.

Phew!

See my finished code...


register_post_type(
'individual',array(
'label' => 'Individuals',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false,
'query_var' => true,
'exclude_from_search' => false,
'supports' => array(
'title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes'
),
'taxonomies' => array(
'type'
),
'labels' => array (
'name' => 'Individuals',
'singular_name' => 'Individual',
'menu_name' => 'Individuals',
'add_new' => 'Add Individual',
'add_new_item' => 'Add New Individual',
'edit' => 'Edit',
'edit_item' => 'Edit Individual',
'new_item' => 'New Individual',
'view' => 'View Individual',
'view_item' => 'View Individual',
'search_items' => 'Search Individuals',
'not_found' => 'No Individuals Found',
'not_found_in_trash' => 'No Individuals Found in Trash',
'parent' => 'Parent Individual'
),
'menu_icon' => get_bloginfo('template_url').'/images/menu_icon.png'
)
);
register_taxonomy('individual-group',array (
0 => 'individual',
),array( 'hierarchical' => true, 'label' => 'Group Number','show_ui' => true,'query_var' => true, 'rewrite' => false,'singular_label' => 'Group Number') );
register_taxonomy('individual-role',array (
0 => 'individual',
),array( 'hierarchical' => true, 'label' => 'Role','show_ui' => true,'query_var' => true, 'rewrite' => false,'singular_label' => 'Role') );
register_taxonomy('individual-territory',array (
0 => 'individual',
),array( 'hierarchical' => true, 'label' => 'Territory','show_ui' => true,'query_var' => true, 'rewrite' => false,'singular_label' => 'Territory') );