wordpressurl-rewritingslug

Add specific words to WordPress custom type slug


I have a WordPress installation with a custom type (places) which produces this permalink structure:

http://example.com/places/the-first-site/

And I would like to show all my sites like this:

http://example.com/places/visit-the-first-site-and-enjoy/

where 'visit' and 'and-enjoy' would be always those specific words (constants).

Even better I would like to put a custom taxonomy I have (year) as a metadata

places/visit-the-first-site-and-enjoy-1985/

I can access the DB and modify the post name of all post, but I would have to do for the new post also, and I'm looking for some automated rule, but can't find how to do.

Maybe some rewrite rule, but I don't know how to do it.

Any ideas?


Solution

  • You do not have to edit anything in your database nor any codes in your WordPress installation; you can achieve that directly from your WordPress administration panel.

    From your Dashboard, click on the Permalink sub-menu under Settings; there, you will have to select the Custom Structure option and set it as follow in order to achieve your desired effect:

    /places/visit-%postname%-and-enjoy-%year%/

    Please note: here, we made use of both %postname% and %year% Structure Tags so as to get names of posts with their corresponding year of publication respectively.

    Don't forget to click on the Save Changes button on the page in order to effect your changes.

    ... Read more on Permaklinks (for general knowledge).

    For a custom post type and taxonomies as expressed further in comments, you will need a custom solution which will require a little bit of coding and or tweaking, depending on your abilities; you may use this handy plugin (Custom Post Type Permalinks) from the WordPress.org Plugins repository.

    This posts should equally be of great help to you, to getting started and understanding further, should you chose to code.