I have custom post structure like this:
mysite.com/custompostname/customposttitle
and i need to have one more custom post type that have depedency with myfirst custom post type so my permalink would be:
mysite.com/custompostname/customposttitle1/custompostname2/custompost2title1
mysite.com/custompostname/customposttitle1/custompostname2/custompost2title2
mysite.com/custompostname/customposttitle2/custompostname2/custompost2title3
mysite.com/custompostname/customposttitle2/custompostname2/custompost2title4
etc..
I to have news section for my custom posts in permalink, for example:
mysite.com/companies/company1/news/news1
Is there way to achieve this?
You can customise the permalink for a custom post type, but it needs to be hardcoded in the rewrite parameter given to register_post_type. You could use categories to achieve the same thing though: set up a taxonomy for the first custom post type and then use the posts to create a custom taxonomy for the second CPT (i.e. the posts from the first CPT would become the categories for the second).
So you would add something like this pseudo-code to the edit page for the second CPT:
get all posts of type 'CPT1'
loop through them to create a list of checkboxes
display in a metabox
save the result
There are still hoops to be jumped through to get those URLs going to the right place, but it's a start.
Related
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
I have many custom post types and custom taxonomies such as "video" custom post type and "video_category", "product" and "product_category" and so on...
All the products are displayed at website.com/shop but if I get to an archive the permalink become website.com/product_category/"categoryname" and the single post has a link like website.com/product/"productname".
I have googled and found out about link rewriting but... don't really know where to start.
I'd like to have the links above become website.com/shop/"categoryname" and website.com/"categoryname"/"productname".
I could simply change the taxonomy name to "shop" for the first case but that would not be really clean, those are categories after all.
I have a problem with WordPress Custom Post Types that I can't seem to wrap my head around.
I would like to have a category or a custom taxonomy checkbox on my custom post type, and if this one is checked, then display the post in the WordPress main loop and in the WordPress feed.
Note: I don't want to display all posts from my custom post type in the main loop and feed, only the ones that are checked.
Is this even possible to achieve? I've tried to google for a solution, but with no luck so far.
Thanks!
// Jens.
When creating a custom post type and fill it with some posts wordpress generates a page for that custom post type.
But I want to be able to add content to that page so I create a regular page and choose a template where I manually call the custom post type posts and loop them out. And now I can just add content in the wysiwyg editor. But this causes a conflict between these two pages, especially if the CPT has the same name as the page.
And now the question: Is there a way to always show the page where I have chosen the template for the CPT to always show? Even when someone try's to manually enter the url for the CPT generated page?
Here is what I understood from your question. You have custom post type. Then you created a page-template, that loops through your custom post types and output them. Now when you create a new page and assign it the page-template you have created you run into problems, if it has the same name as the custom post type.
Solution: I think what you need to do is change the custom-page slug from the admin menu. Then you would be able to directly reference it by the URL.
I want to show custom taxonomies. But when I try to show only taxonomies wordpress takes me to 404 page.
I have taxonomy TV Series, and I can show All the terms in the TV Series Taxonomy by utilizing template {taxonomy-tv_series.php} "tv_series" is the taxonomy name. Bellow is the working url.
http://mysite.com/tv-series/lost/
and I can show all the posts inside the lost on {taxonomy-tv_series.php}. But I want to show / list all the tv-series itself like
tv-series-template.php and it displays.
a) Lost b) Prison Break c) Breaking Bad etc.
by using url like this
http://mysite.com/tv-series/
If my question is not clear to you guys, please let me know I will try to make it more usefull.
I am using pretty permalink "%spost_name%s"
Thanks.
Currently WordPress doesn't offer an archive that displays everything tagged inside a taxonomy.
You could create a custom page template called "TV Series" and manually query all posts associated with your taxonomy.
Alternatively you could create a custom post type e.g. called "Tv Show" and connect it to your taxonomy. Then you would use archive-{post-type}.php to display all posts inside your taxonomy.
You can read more about template hierarchy at the codex page:
http://codex.wordpress.org/Template_Hierarchy