WP Rewrite - Add post ID to URL - wordpress

I have a custom post type (job) in my WordPress theme.
Posts of this type are inserted by users themselves, but if two or more jobs are inserted with the same title, the slug will be:
www.mydomain.com/job/title-choosen-by-user
www.mydomain.com/job/title-choosen-by-user-2
www.mydomain.com/job/title-choosen-by-user-3
...
Is it possible to keep the same slug and add the post ID in the URL using any rewrite? The result would be:
www.mydomain.com/job/100/title-choosen-by-user
www.mydomain.com/job/101/title-choosen-by-user
www.mydomain.com/job/102/title-choosen-by-user
...
Any help would be appreciated.
Thank you

Perhaps try changing your permalink structure in Settings > Permalinks under the WP admin dashboard.
Try:
/%post_id%/%postname%/

Ok I found a small but working tutorial for custom permalinks structure
http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2

Related

Permalinks for CustomPostType with CustomTaxonomy in WordPress

Using CPT UI I created a taxonomy "especialidades" and a post type "tab_especialidad" using my new taxonomy "especialidades".
I need the permalinks of the "tab_especialidad" post types like this:
http://webpage.com/especialidades/[taxonomy-slug(especialidades)]/[post-slug(tab_especialidad)]
Is this possible?
I found the solution here: https://wisdmlabs.com/blog/add-taxonomy-term-custom-post-permalinks-wordpress/
With just a small changes in my functions.php it's working :)

.htaccess rewrite url with string URI is number

I have a website which was built with wordpress CMS. I want to change it to another theme with custom post type.
it's current url looks like:
mysite.com/1234 - links for posts - 1234 is id of the post
mysite.com/topic/cate-name - is link for categories
mysite.com/tag/tag-name - link for tags
now when i change to new theme and convert all post type, categories, tags, it causes some change likes:
mysite.com//video/1234
mysite.com/cate-vid/cat-name
mysite.com/tag-vid/tag-name
Please help me to rewrite my url with .htaccess for both apache and nginx serivce.
Thank you very much!

web.com/post/post-title redirects to web.com/post-title

I'm having a complain of the SEO guy because a post url is not like this
web.com/blog/post-title
But like this
web.com/post-title
And even web.com/blog/post-title redirects to web.com/post-title
How could I restore normal behavior? it looks like they are being treated as page but they work as posts in web.com/blog
Go to Settings -> Permalink
Choose the Custom structure and fill the value with /blog/%postname%/
Need to update the htaccess inorder to get the old path works OR you can set the permalink is to /blog/%postname%/ like this
Please refer this link:
https://wordpress.stackexchange.com/questions/19238/how-do-i-add-blog-as-a-prefix-to-permalink-structure-for-blog-posts-tag-pages

Wordpress ignoring custom permalinks structure

I have a custom structure for permalinks (Wordpress 3.9.1 + Types 1.5.7) like this:
/%post_id%
But wordpress returns me something like this:
/post-type/%postname%
It seems like wordpress overwrites my post_id param. Any idea?
Try this :
/%post-type%/%postname%/
If that doesn't work check the codex Wordpress codex
I'd also look into using tags, categories, or taxonomies as a possible solution (again, check the codex-I've got no idea)

Rewrite category wordpress

Is it possible to rewrite only one category ?
I have a category "Photos" and just for this category.
I just want to rewrite it from /category/photos to /photos
You can do it with WP Rewrite API.
Add this to functions.php
add_action('init', 'register_rewrites');
function register_rewrites() {
add_rewrite_rule('^photos$', 'index.php?category_name=photos','top');
}
Remember to reload your rewrite settings: go to Settings -> Permalinks and click on Save button - no changes needed.
The Yoast SEO plugin has this function build in, I recommend this plugin in general.
no-category-base-wpml only does this
If you don't want to install a plugin for this. Around the web there are many tutorials which do this:
http://thisismyurl.com/6704/remove-category-url-wordpress/
http://www.webdevtuts.net/php/how-to-remove-category-from-wordpress-url-structure/
http://www.wprecipes.com/how-to-remove-category-from-your-wordpress-url
Too enable this for just one category I would advise the following:
create a page called photos.
create a theme template page for this photo page
In is set up a new query_posts* getting the category 'photos'
Include the category.php file.
assign that template to the photo page.
Not tested but should work. Because the page has the correct URL and should include the category. Questions, aks.
*query_posts is bad for performance if you want to do it totally correct use the pre_get_posts filter. It's requires more knowledge.

Resources