admin管理员组文章数量:1417672
So I tried to make a simple plugin for WordPress. Like a reviews. Even tried to do it through the tutorial of TutsPlus. Everytime I got 404 when tried. Then I just took the code from tutor and still got 404 on viewing my review post type post.
function my_custom_posttypes() {
$labels = array(
'name' => 'Testimonials',
'singular_name' => 'Testimonial',
'menu_name' => 'Testimonials',
'name_admin_bar' => 'Testimonial',
'add_new' => 'Add New',
'add_new_item' => 'Add New Testimonial',
'new_item' => 'New Testimonial',
'edit_item' => 'Edit Testimonial',
'view_item' => 'View Testimonial',
'all_items' => 'All Testimonials',
'search_items' => 'Search Testimonials',
'parent_item_colon' => 'Parent Testimonials:',
'not_found' => 'No testimonials found.',
'not_found_in_trash' => 'No testimonials found in Trash.',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-id-alt',
'query_var' => true,
'rewrite' => array( 'slug' => 'testimonials' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail' )
);
register_post_type( 'testimonial', $args );
}
add_action( 'init', 'my_custom_posttypes' );
// Flush rewrite rules to add "review" as a permalink slug
function my_rewrite_flush() {
my_custom_posttypes();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'my_rewrite_flush' );
on top was php opening tag and plugin info (as usual). Tried it with several themes - still got 404. Before every test I saved changes on Permalinks and deactivated && activated that plugin.
Anyone got any ideas? I'm just learning for now (yesterday started).
So I tried to make a simple plugin for WordPress. Like a reviews. Even tried to do it through the tutorial of TutsPlus. Everytime I got 404 when tried. Then I just took the code from tutor and still got 404 on viewing my review post type post.
function my_custom_posttypes() {
$labels = array(
'name' => 'Testimonials',
'singular_name' => 'Testimonial',
'menu_name' => 'Testimonials',
'name_admin_bar' => 'Testimonial',
'add_new' => 'Add New',
'add_new_item' => 'Add New Testimonial',
'new_item' => 'New Testimonial',
'edit_item' => 'Edit Testimonial',
'view_item' => 'View Testimonial',
'all_items' => 'All Testimonials',
'search_items' => 'Search Testimonials',
'parent_item_colon' => 'Parent Testimonials:',
'not_found' => 'No testimonials found.',
'not_found_in_trash' => 'No testimonials found in Trash.',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-id-alt',
'query_var' => true,
'rewrite' => array( 'slug' => 'testimonials' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail' )
);
register_post_type( 'testimonial', $args );
}
add_action( 'init', 'my_custom_posttypes' );
// Flush rewrite rules to add "review" as a permalink slug
function my_rewrite_flush() {
my_custom_posttypes();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'my_rewrite_flush' );
on top was php opening tag and plugin info (as usual). Tried it with several themes - still got 404. Before every test I saved changes on Permalinks and deactivated && activated that plugin.
Anyone got any ideas? I'm just learning for now (yesterday started).
Share Improve this question edited Aug 5, 2015 at 0:44 davisdev asked Aug 5, 2015 at 0:37 davisdevdavisdev 113 bronze badges 4- 404 where? Trying to access what? – jdm2112 Commented Aug 5, 2015 at 0:45
- Trying to view the review! Please, try to read the text first! – davisdev Commented Aug 5, 2015 at 1:00
- screencloud/v/gQog is it clear now? – davisdev Commented Aug 5, 2015 at 1:01
- After the edit, yes. It helps to be clear when asking a question you want an answer to. – jdm2112 Commented Aug 5, 2015 at 1:46
1 Answer
Reset to default 0It might be an .htaccess issue. Sometimes I try to flush the rewrite rules from the command line and it doesn't rewrite the .htaccess file until I go into the /wp-admin section, go to 'Settings > Permalinks' and just save it without making any modifications. See if that works.
本文标签: pluginsflush rewrite rules doesn39t flush them (still got 404)
版权声明:本文标题:plugins - flush rewrite rules doesn't flush them (still got 404) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745276660a2651228.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论