So I have website on a WordPress engine. And I want to make posts urls looks like http://website.com/blog/post-name/ or http://website.com/blog/categ-name/post-name/. But everything else will look like http://website.com/page-name/. Just want to add prefix 'blog' to urls for all posts but not pages. My permalink settings is /%postname%/. If i will put /blog/%postname%/ I will have 'blog' prefix in every URL of my site :( I can't find solution in WordPress admin backend and I didn't find any acceptable plugin for this. Any help is appreciated, thanks.
A Search Console property that, as defined, includes the protocol (http or https) and can include a path string when you created the property. You can see the property URL in the property selector dropdown. Examples of URL-prefix properties: https://m.example.com/petstore/
Changing Custom Post Type Permalinks in WordPress Upon activation, you need to visit Settings » Permalinks page and scroll down to 'Permalink Settings for Custom Post Types' section. Here you can change the permalink structure of single items in your custom post type.
You need to visit the Settings » Permalinks page from your WordPress dashboard and scroll down to the 'Optional' section. In the 'Category base' field, you can enter the prefix you would like to use next to the category base option. You can also change the tag base prefix if you want.
SImply login to your WordPress dashboard and go to Settings » General. Here, you can change your WordPress site URLs in the 'WordPress Address' and 'Site Address' boxes. For most websites, these will be the same URL. After that, click the 'Save Changes' button to save your URL changes.
I did this:
add_action( 'init', 'redefine_post', 1 );
function redefine_post() {
register_post_type( 'post', array(
'labels' => array(
'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),
),
'public' => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array( 'slug' => 'blog' ),
'query_var' => false,
'has_archive' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
) );
}
It involves creating a custom post type (which is slightly annoying), but it overrides and works with post.
I wish there was a better way of doing this! (Otherwise yes you get /blog/ in front of everything if you just change the permalinks).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With