$18
Custom Post Types display only 404
Here are the details:
- This is the main site of a MultiSite install running the 3.0.1
- Site runs the "remove /blog/" plugin (http://thinkinginwordpress.com/)
- Permalink structure: /archives/%postname%
- custom post type permalink should be /%customposttype%/%postname%
The Custom Post Type
add_action( 'init', 'register_cpt_faqs' );
function register_cpt_faqs() {
register_post_type( 'faqs',
array(
'labels' => array(
'name' => __( 'FAQs' ),
'singular_name' => __( 'FAQ' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New FAQ' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit FAQ' ),
'new_item' => __( 'New FAQ' ),
'view' => __( 'View FAQ' ),
'view_item' => __( 'View FAQ' ),
'searemperor_items' => __( 'Search FAQs' ),
'not_found' => __( 'No FAQs found' ),
'not_found_in_trash' => __( 'No FAQs found in Trash' ),
'parent' => __( 'Parent FAQ' ),
),
'public' => true,
'show_ui' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'menu_position' => 20,
'hierarchical' => false,
'query_var' => true,
'supports' => array( 'title', 'editor', ),
'rewrite' => array( 'slug' => 'faqs', 'with_front' => false ),
'taxonomies' => array('faqtags' ),
'can_export' => true,
)
);
}
add_action( 'init', 'register_taxonomy_faq', 0 );
function register_taxonomy_faq() {
register_taxonomy( 'faqtags',
array( 'faqs' ),
array(
'public' => true,
'show_ui' => true,
'show_tagcloud' => true,
'show_in_nav_menus' => true,
'hierarchical' => false,
'labels' => array(
'name' => __( 'FAQ tags' ),
'singular_name' => __( 'FAQ tag' ),
'searemperor_items' => __( 'Search FAQ tags' ),
'popular_items' => __( 'Popular FAQ tags' ),
'all_items' => __( 'All FAQ tags' ),
'parent_item' => __( 'Parent FAQ tag' ),
'parent_item_colon' => __( 'Parent FAQ tag:' ),
'edit_item' => __( 'Edit FAQ tag' ),
'update_item' => __( 'Update FAQ tag' ),
'add_new_item' => __( 'Add New FAQ tag' ),
'new_item_name' => __( 'New FAQ tag' ),
),
'query_var' => 'faqtags',
'rewrite' => array( 'slug' => 'faqtags', 'with_front' => true ),
)
);
}The htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
Matt Taylor | 08/25/10 at 3:29pm
| Edit
(7) Possible Answers Submitted...
-

Last edited:
08/25/10
3:31pmUtkarsh Kukreti says:Have you tried resaving the Permalinks from Settings?
- 08/25/10 3:32pm
Matt Taylor says:Yes, of course.
- 08/25/10 3:32pm
-

Last edited:
08/25/10
3:46pmMilan Petrovic says:Try my plugin GD Custom Posts And Taxonomies Tools:
free version: http://wordpress.org/extend/plugins/gd-taxonomies-tools/
pro version: http://dv4p.com/gdtt
It's made to ensure that everything is registered properly, rewrite rules flushed when needed and more. It's easy to make mistake and waste days in finding problems if you code everything manually like you did.- 08/25/10 3:49pm
Matt Taylor says:Thanks Milan but we are looking for a plugin-free solution.
- 08/25/10 3:49pm
-

Last edited:
08/25/10
4:19pmPatrick Daly says:I doubt this is causing the issue, but your
has duplicate lines. Delete the last two. In fact, I'd just delete the whole thing and re-save your permalink structure.htaccessPrevious versions of this answer: 08/25/10 at 4:19pm
- 08/25/10 5:28pm
Patrick Daly says:Add those functions to the Twenty Ten theme and see if it works.
- 08/25/10 5:34pm
Matt Taylor says:Adding the code exactly in TwentyTen still produces a 404.
- 08/25/10 5:46pm
Patrick Daly says:I just setup a test install, copied and pasted your code into the Twenty Ten functions.php, changed the permalinks to /archives/%postname%/ and the result: http://test.clients.developdaly.com/faqs/test/
So it works for me. My htaccess ended up being:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]
You might also try leaving your permalinks default, like so: http://test.clients.developdaly.com/?faqs=test
If you've done everything above then maybe your WordPress install is broken or you've got some funky server settings.
- 08/25/10 5:28pm
-

Last edited:
08/25/10
4:20pmStephanie Leary says:Ethan, is your type/taxonomy code in a plugin file or functions.php? If it's in a plugin, try adding an activation hook so the rewrite rules get flushed just once, like this:
register_activation_hook( __FILE__, 'activate_faq_post_types' );
function activate_faq_post_types() {
register_cpt_faqs();
register_taxonomy_faq()
$GLOBALS['wp_rewrite']->flush_rules();
}- 08/25/10 4:30pm
Matt Taylor says:Its in the functions file. But thanks. :)
- 08/25/10 4:30pm
-

Last edited:
08/25/10
5:05pmBaki Goxhaj says:Dublicate your single.php or or index.php into single-faqs.php - this is how you show the posts of your custom post type on single view. After that you can do your changes accordingly.
I would like to help you on-site, if you cannot solve this alone.- 08/25/10 5:16pm
Matt Taylor says:Thanks Baki. That too though has already been done.
- 08/25/10 5:18pm
Baki Goxhaj says:Can I have a look on-site? banago-at-gmail.com
- 08/25/10 5:16pm
-

Last edited:
08/25/10
6:31pmMichelle Dancer says:Do the links work correctly with default permalink structure, but 404 when you change it? If so I had a similar problem and the way I found to finally fix it was to add:
flush_rewrite_rules( false );
just before the closing tag of my custom post types function, in your case register_cpt_faqs().
After that reset the permalinks for good measure and fingers crossed it'll work for you too.- 08/25/10 6:31pm
Matt Taylor says:That was what I was missing. Thanks!
- 08/25/10 6:31pm
-

Last edited:
08/25/10
6:04pmMichael Fields says:Delete this line:
'rewrite' => array( 'slug' => 'faqs', 'with_front' => false ),
This question has expired.
Current status of this question: Completed




