WordPress: Same Permalink structure for pages, a custom post type and a taxonomy? - wordpress

Is it possible to have the same permalink structure for pages, a custom post type and a custom taxonomy. The desired permalink for them all is http://sitename.com/{slug}
How can I achieve that?

You can use plugin custom permalink. By using this plugin you can set url as u want.
http://wordpress.org/plugins/custom-permalinks/

Short answer: Yes and No. You can code something up yourself, create some fancy .htaccess rules or use a combination of plugins.
See this post, despite its name, someone does suggest a plugin - I've used the plugin they talk about (wp-no-category-base), it does the job. Be aware that you could be asking for trouble doing this (for instance if you try to label a particular post with the same name as the category/custom taxonomy/etc - read the accepted answer here: https://wordpress.stackexchange.com/questions/42120/remove-slug-in-taxonomy-url):
Remove category & tag base from WordPress url - without a plugin
I'm fairly sure it handles custom post types - can't remember. If not, check out this:
https://github.com/markoheijnen/wp-no-taxonomy-base
Note: this code has not been updated in a long time.

Related

How to create Wordpress' permalinks after creating a custom post type?

I just created a custom post type called products in Wordpress. When I select plain permalinks, the links work fine. When I select any other permalink, the URL cannot be found.
For instance, http://localhost/TheGrind/?products=gopro-hero6-black is my permalink with the plain option selected. And http://localhost/TheGrind/product/gopro-hero6-black/is the permalink that I'm looking to use for my posts. I get a
Not Found
The requested URL /TheGrind/product/gopro-hero6-black/ was not found on this server.
The question is how can I get this type of URL to work when I create a custom post type in Wordpress.
Any help is greatly appreciated.
You could try adding
flush_rewrite_rules();
after you have called
register_post_type();
That has fixed the issue for me in the past.
If it does work for you, you can then remove the "flush_rewrite_rules();" as WordPress states it is an expensive operation.
https://codex.wordpress.org/Function_Reference/flush_rewrite_rules

Parent permalink slug before CPT slug

I'm currently busy making a FAQ for my website but i'm struggling with the permalink structure.
I have made a regular page where people can see an overview of the FAQs. I called that page Klantadvies.
I installed a Custom Post Type plugin and made a post type called faq. I also made a taxonomy which is called onderwerp.
Unfortunately the plugin won't allow me to have a page parent in the slug. So i'm wondering if it's possible to have my page slug (klantadvies) in front of the custom post type slug. For example:
http://mypage.com/klantadvies/faq/onderwerp
Thnx in advance!
Rather than using a plugin for your post types and taxonomies, I'd recommend you use these two solutions:
https://generatewp.com/post-type/
https://generatewp.com/taxonomy/
You can use those to create your Post Type and Taxonomies. Within each of those configs you're allowed to setup the slugs / URL structure that you want to use.
On top of that you're going to need to setup a custom rewrite rule to handle echoing out the values you're looking for on the appropriate layout.
https://codex.wordpress.org/Rewrite_API/add_rewrite_rule

how can i create archives for custom post type

the WordPress framework allows to build different archive templates for each of your custom post type by e.g:
archive-event.php
taxonomy-event_category.php
is it possible to create author and date archive for custom post type by doing the following:
author-event.php
date-event.php
if this is not possible, can anyone advise how i can go about achieving this?
I think these links will help answer your question and get you started:
http://codex.wordpress.org/Template_Hierarchy
http://codex.wordpress.org/Category_Templates
The gist of it is that you can in fact make an author-event.php however date-event.php does not get checked because the template hierarchy dictates that it uses date.php, archive.php, or index.php.
One solution is to use conditional tags such as is_author() or is_date(). If you do, keep in mind that you'll have to have a common archive.php and decide which template you really want to use by using conditional tags.

Creating a custom permalink structure based on post fields

I am wondering if it is possible to create a bespoke permalink structure which is based off some of the custom fields I have in my post.
The custom post fields are: film_director, film_name (these will be consitent through out the website)
So the structure I would like to create is as follows:
http://domain.com/%film_director%/%film_name%/%postname%
I'm not great with Wordpress specific terminology so I might just be looking with the wrong keywords however is this something that can be completed (with use of either a plugin or custom code)
Thanks :)
Yep you can do this : here is a nice tutorial about it : http://firecask.com/custom-fields-and-posts-in-wordpress-permalink-urls/
I also find a plugin which seems to do this, but it's quite an old one. http://wordpress.org/plugins/custom-fields-permalink/

Wordpress custom post type and permalink rewriting

I'm struggling with a problem I'm not able too solve.
I've spent a lot of hourse in codex documentation without any luck.
I've created a custom post type called "Products". Products will be available in many language. Products permalink is something like: mysite.com/products/product-name What I need instead is something like this: mysite.com/language/products/product-name.
What I need to create the permalink? Have I to add some fancy rule with WP_Rewrite?
Is it possibile to have custom post type as page child's?
I don't really need custom taxonomy so if you know a better solution fell free to write.
Thanks for any suggestion.
You need a plugin for wordpress to gracefully handle multiple languages.
I suggest you check out wpml.org
For how the Wordpress Multilingual plugin works with custom posts types, check out their informative blog post.

Resources