[英]WordPress: Move blog to page
我需要将WordPress博客条目移至页面。
我已经将WordPress安装到子文件夹( http://example.com/canada/
),当前我使用以下URL访问我的Blog条目: http://example.com/canada/hello-world/
: http://example.com/canada/hello-world/
但是我想这样称呼我的Blog条目: http://example.com/canada/blog/hello-world
: http://example.com/canada/blog/hello-world
。
我知道我可以在Options -> Reading
下为我的条目选择一个静态页面。 但是,如果我将进入页面的选项设置为“博客”,则不会发生任何事情。
有谁知道如何解决这个问题?
当然,在Settings > Permalinks
设置以下自定义结构:
/blog/%postname%/
我自己解决了这个问题...我定义了一个名为blog的新自定义帖子类型 。 如我所见:)
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');
不要忘记刷新您的永久链接。 否则,您会得到404。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.