WordPress: Move blog to page
i need to move my WordPress Blog Entries to a page.
I've installed WordPress to subfolder (http://example.com/canada/
) and currently i access my Blog entries with following URL: http://example.com/canada/hello-world/
But i would like to call my Blog entries like this:开发者_运维知识库 http://example.com/canada/blog/hello-world
.
I know i can choose a static page for my entries under Options -> Reading
. But if i set the option for entry page to Blog nothing happends.
Does anyone know how to solve this?
Sure, in Settings > Permalinks
set the following Custom Structure for your permalinks:
/blog/%postname%/
I solved the problem my own... I've defined a new custom post type named blog. Works as i aspected :)
Working Solution:
function post_type_blog() {
$labels = array(
'name' => _x('Entries', 'post type general name'),
'singular_name' => _x('Entry', 'post type singular name'),
'add_new' => _x('Add', 'entry'),
'add_new_item' => __('Add new Entry'),
'edit_item' => __('Edit'),
'new_item' => __('New'),
'view_item' => __('Visit'),
'search_items' => __('Search Entries'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'page',
'hierarchical' => false,
'rewrite' => array("slug" => "blog"), // Permalinks format
'menu_position' => 5,
'supports' => array('title','editor','thumbnail','comments')
);
register_post_type('blog',$args);
}
add_action('init', 'post_type_blog');
Important note:
Don't forget to refresh your permalinks. Otherwise you'll get an 404.
精彩评论