Changing wordpress posts URL - wordpress

I have a wordpress website with bunch of posts. My problem is that I need to change the URLs from
website.com/post-name
to
website.com/specialword/post-name
The "specialword" is what I need to add in front of those post names, but ONLY for the post type - posts.
Can someone help me?
I need this badly, mostly because of the SEO purposes so I can keep the URLs from the previous website that wasn't done in wordpress.
Thank you!

To have "/specialword/" appear in the "post" (blog) url, you need to set "Custom Structure" in permalinks to "/specialword/%postname%".
Then, to NOT have /specialword/ appear in a custom post type url, you need to set "with_front" to false when registering the custom post type, like this:
"rewrite" => [ "slug" => "myposttype", "with_front" => false ]

Go to Settings -> Permalinks
Select Custom Structure
Fill in with /specialword/%postname%
Screenshot:

Related

Custom permalinks structure for custom posts

I have a SEO problem as the structure of the site on WordPress is squad.
The site has ordinary cutters and are custom. They are structurally interested in information, but not in the URL. The task of tie them. The solution has never been found on the Internet.
Example:
Page
https://website.com/page1
https://website.com/page2
Custom Post Type
https://website.com/custom/page1/post1
https://website.com/custom/page2/post2
I need cut /custom/ and put this post1 under page1 of that page and another posts under another pages.
In register_post_type I was made rewrite
`
'rewrite' => [
'slug' => '/',
'with_front' => false
],
`
so this remove my /custom/. Can any say me where I can find guide how to transfer this custom_post_type under /page*/?
I tried change permalinks via permalinks plugin, but it doesn't solve my issue.

Wordpress "custom post type permalinks" plugin generates 404 Page not found

I need the links of all personalized posts and taxonomies to be structured with the name of the category (s) they belong to.
Unfortunately the theme used for my site generates a new type of post and the new taxonomy programmatically and performs the rewrite of their permalink.
To solve this problem I configured the "Custom Post Type Permalinks" plugin which works, but only halfway:
- the permalinks of taxonomies are generated correctly and are accessible from the site.
- the permalinks of the posts are generated correctly, but are not accessible from the site and return a page with a "404 Page not found" error.
In my httpd.conf the line LoadModule rewrite_module modules/mod_rewrite.so is not commented.
What can I do?
let me give you a deeper idea about what we’d like to get. We would really appreciate if you could help us reaching it, by letting us know where to operate.
We would like all the tours’ url to be made up like this: www.sitename.com/$category_father/$category_child/$name_of_my_post Moreover, we would like all the tours’ taxonomies url to be made up like this: www.sitename.com/$category_father/$category_child
At the moment your Tourmaster plugin creates the taxonomies and the tours as below:
www.sitename.com/tour/$name_of_my_post
www.sitename.com/tour-category/$category_child
In order to avoid editing the plugin code and prevent any updates conflicts we installed the plugin “Custom Post Type Permalinks”. It partially solves the taxonomies problem and partially the tours one, generating almost correct urls which are unfortunately not reachable.
www.sitename.com/tour/$category-father/$category_child/$name_of_my_post
www.sitename.com/tour/tour-category/ $category_father/$category_child
Referring to the readme.txt file within www.sitename.com/wp-content/plugins/custom-post-type-permalinks/ we could notice the following example code.
register_post_type( 'foo',
array(
"public" => true,
'has_archive' => true,
"rewrite" => ["with_front" => true],
"cptp_permalink_structure" => "%post_id%"
) );
So we edited the Tourmaster plugin code replacing the rewrite array within the file www.sitename.com/wp-content/plugins/tourmaster/include/tour-option.php with the array [“with_front” => true], but we did not get any result. When you saw the url working, it was due to a temporary reset of the CPTP settings.

Show different URL in address bar

I have a custom post with post-type "podcast" and now my podcast post single URL is http://localhost/sitename/blog/podcast/post-name. But I want to show post-type "podcast" URL like: http://localhost/sitename/test/podcast/post-name.
Currently site permalink is set to custom structure with /blog/%postname%. So blog is showing with each custom post type. And I want to keep permalink structure same but blog will not show in "podcast" post URL.
I have already created a new file for single podcast with copied single.php and changed name to single-podcast.php. It's working fine with http://localhost/xyz/blog/podcast/post-name but I want to show different name in URL.
Can you please suggest a solution for this?
Have you tried rewrite options?
https://codex.wordpress.org/Function_Reference/register_post_type#Parameters
Example:
[
'rewrite' => [
'slug' => 'your/custom/post/slug/here',
'with_front' => false,
],
]

wordpress - Issue With custom post types and permalinks

I'm working with Custom Post Types for the first time and running into a vexing problem:
I can add and query the post types, but they always show up as:
domain.com/post-type-name/post-title
I have no rewrite in place, and my permalink structure is set to %postname% only, and I am flushing the rules immediately following adding the post type.
Any ideas on what I'm doing wrong?
This could be helpful to solve the problem:
http://www.ultimatewebtips.com/remove-slug-from-custom-post-type/
You may try two things
Just visit your Permalink Settings from the settings menu and save the page again.
or you may try
register_post_type('post-type-name', array(
//...
'rewrite' => array('slug'=>'','with_front'=>false),
//...
));

How to rewrite URI of custom post type?

The site that I am working on uses the following "pretty" permalink structure:
http://example.com/blog/my-special-post
But for a custom post type my client would like to avoid having a "pretty" slug:
http://example.com/product/142
How can the post ID be used in place of the slug?
I believe that this might be possible using WP_Rewrite, but I do not know where to begin.
I posted the same question on WordPress stack exchange site and received a good solution:
WordPress StackExchange - How to rewrite URI of custom post type?
All of WP's posts/pages, regardless of their type, can be reached via http://example.com/?p=foo, where foo is the post ID.
By default, redirection to a "pretty permalink" takes place though.
On the WP Codex entry for register_post_type() (I assume that's what you're using to set up your CPT, right?), the rewrite argument is described:
rewrite
(boolean or array) (optional) Rewrite permalinks with this format. False to prevent rewrite.
Default: true and use post type as slug
So, using
$args = array(
'rewrite' => false,
// ... whatever else there is
);
register_post_type('product', $args);
should yield what you're looking for.
In the WP admin you can chane the display of the permalinks by going to 'Settings->Permalinks'. To achieve your desired results, set the custom structure to /%post_id%/. Unless you manually edit .htaccess and the WP rewrite rules, I don't think you can achieve a structure where you have the post slug in the URI for one post type, but the ID for another.

Resources