I have created a custom post type
public function register_post_types() {
$args = array(
'labels' => array(
'name' => 'Android Apps',
'singular_name' => 'Android App',
'add_new' => 'Add New App',
'add_new_item' => 'Add New App',
'edit_item' => 'Edit App',
'new_item' => 'New App',
'view_item' => 'View App',
'search_item' => 'Search App',
'not_found' => 'No Apps Found',
'not_found_in_trash' => 'No Apps Found in Trash'
),
'query_var' => 'apps',
'rewrite' => array(
'slug' => 'apps',
),
'public' => true,
'has_archive' => true,
'menu_position' => 5,
'menu_icon' => admin_url(). 'images/media-button-video.gif', //Icon url
'supports' => array(
'title',
'thumbnail',
'editor',
)
);
register_post_type('apps', $args);
flush_rewrite_rules();
}
The posts give a 404 on this style of permalinks http://site/apps/flashlight
Although they work fine on plain permalinks http://site/?apps=flashlight
I have created a custom post type
public function register_post_types() {
$args = array(
'labels' => array(
'name' => 'Android Apps',
'singular_name' => 'Android App',
'add_new' => 'Add New App',
'add_new_item' => 'Add New App',
'edit_item' => 'Edit App',
'new_item' => 'New App',
'view_item' => 'View App',
'search_item' => 'Search App',
'not_found' => 'No Apps Found',
'not_found_in_trash' => 'No Apps Found in Trash'
),
'query_var' => 'apps',
'rewrite' => array(
'slug' => 'apps',
),
'public' => true,
'has_archive' => true,
'menu_position' => 5,
'menu_icon' => admin_url(). 'images/media-button-video.gif', //Icon url
'supports' => array(
'title',
'thumbnail',
'editor',
)
);
register_post_type('apps', $args);
flush_rewrite_rules();
}
The posts give a 404 on this style of permalinks http://site/apps/flashlight
Although they work fine on plain permalinks http://site/?apps=flashlight
You are missing with_front
in rewrite
which is true
by default. Change it to something like this
'rewrite' => array(
'slug' => 'apps',
'with_front' => false,
)
See the docs