Skip Navigation

[Resolved] Region and Country post relation

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 replies, has 2 voices.

Last updated by Christian Cox 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#759134

Hi,

Watch the following please, hope that shows the issue.

Basically, regions like Africa which are the continents are not the parent of the country like Botswana currently.

hidden link

#763621

It sounds like you want to modify the permalink URL structures for your custom post types so that the directory structure reflects the hierarchy of post relationships. This isn't something that Toolset is designed to accomplish, because it's not how WordPress permalink structures are intended to work. WordPress generates permalinks using the structure http://www.yoursite.com/post-type-slug/post-slug by default. Toolset can help you modify the post type slug or the post slug, but not modify the overall permalink directory structure. Accomplishing a hierarchical directory structure like this in WordPress will require custom code or another 3rd-party custom permalink plugin. A quick search led me to this post that might be helpful:
http://www.thecodex.us/hierarchical-permalinks-based-relationship-2-custom-post-types/

#788859

Hi Christain,

See below please from Jon the guy you referred me too above, I have created a direct here hidden link

However it is empty, I assume due to the view being broken? Also no edit option in the wpadmin bar.

I am not sure how to move this forward really, it seems a simple requirement but...

Thanks
Simon

I am unsure who Christian is, and I am not even really affiliated with Toolset. But I did post a solution that everyone seemed to think was impossible on their forum. Maybe this is why they are referring you to me.

https://toolset.com/forums/topic/permalink-structure-from-post-type-relationships/page/2/

The breadcrumbs you are wanting are a little different than my solution, my solution is to rewrite the url to be /africa/botswana/ in your example. Where africa is one post type (continent for your example, brand in mine) and botswana is another (country in your example, product in mine) that have a parent child relationship set through Toolset. But you could do something similar to generate breadcrumbs based on that post relationship as well.

In your custom breadcrumbs code just get the current post id, then find it's parent id (see line 8) then get the permalink and title using standard WP methods to build your breadcrumbs.

On Wed, May 2, 2018 at 11:01 AM, SIMON BOAKES <simon.boakes@btinternet.com> wrote:
Will this alter the menu navigation as per the master website showing path below

Africa/botswana/tourname

As Christian from toolset referred me to you on the same video saying toolset could not do this but to refer to you.

Do I need to make a clearer video?
Thanks

Sent from Yahoo Mail on Android

On Wed, 2 May 2018 at 15:33, Jonathan Bosley
<jdbosley@gmail.com> wrote:
Toolset Types has a built in way to set relationships between post types. Have you set that part up yet?

https://toolset.com/ documentation/user-guides/ creating-post-type- relationships/

On Tue, May 1, 2018 at 2:19 PM, SIMON BOAKES <simon.boakes@btinternet.com> wrote:
Hi Jonathan,

Yes, please watch this hidden link. uk/vids/owmigration-FG-Joomla- Zoo.mp4

Thanks
Simon

On Tuesday, 1 May 2018, 19:59, Jonathan Bosley <jdbosley@gmail.com> wrote:

Are you attempting to do post type relationship URL rewriting?

On Mon, Apr 30, 2018 at 12:46 PM, WordPress <wordpress@thecodex.us> wrote:
From: Simon <simon.boakes@btinternet.com>
Subject: post to post

Message Body:
Hi

Toolset pointed me to you, can I send you a video of my issue please?

Thanks

--
This e-mail was sent from the contact form on Codex (hidden link)

--
Jonathan Bosley

--
Jonathan Bosley

#788943

Please share some screenshots showing the View editor screen in wp-admin, and copy + paste the code from the Loop Output editor and any Content Templates used in the loop here for me to review. Then please share specific details about how this View was added to the page.

#789108

Christian,

See Functions code, Template, Views and Login details below please.

//handle requests to the new Permalink
add_action( 'init', function() {
add_rewrite_rule('^devices/(.*)/([^/]+)/?$','index.php?odyssey-world-countr=$matches[2]','top');
});
//save the new Permalink structure on Post Edit
add_filter('post_type_link', function($link, $post){
if('odyssey-world-countr' == get_post_type($post)){
//this is the Types Toolset way of looking up a parent
//if you are not using Types Toolset replace this with something applicable to your setup
$parentId = wpcf_pr_post_get_belongs($post->ID,'odyssey-world-region');
if($parentId){
$parent = get_post($parentId);
return str_replace('/odyssey-world-countr/', '/'.$parent->post_name.'/', $link);
}
}
return $link;
}, 10, 2 );

Views can be found from the template from that page Template "countries template"

View linked to that "Tours related to the current Country"

Thanks for looking, again this is a copied area so you can test things as needed

Simon

#789169
Screen Shot 2018-05-02 at 3.35.48 PM.png

This link is 404:
hidden link
You can tell because the page title is "Page not found". That indicates a problem with the permalink structure.

#789292

I removed that function code from Jon and saved the permalinks, so back to how it was before at the moment

#789354

Okay, but I'm not clear what you want me to do. What's the problem?

#789481

I need the nav like this hidden link

So Odyssey-world-region/odyssey-world-countr/Odyssey World country-destination

Should be Africa/Botswana/the-great-north-road-escorted-safari etc and not each Custom post showing its own name like

hidden link
hidden link
hidden link

Currently, the 3 separate custom posts do not allow this, see below Migration company and final thread asking to ask you guys about this.

Frédéric GILLES posted 02/05/2018 14:48
I have seen your video and your site.
If I have well understood your issue, you want to see the relations between country destinations and regions.
The plugin can import all custom post types and all custom taxonomies, but it can't import the relations between two custom post types.
However, I think you can do it pretty easily with Toolset Types by defining a parent/child relationship on this screen : Toolset > Post Types > Odyssey World country-destinations and by setting manually the relationship values on each country destination post

Frédéric GILLES posted 02/05/2018 17:54
Sure.
I have set the relationship in Toolset.
And I have set the parent of the Botswana to "Africa" on hidden link as you can see on the attached screenshot.

simon posted 02/05/2018 19:21
Thanks, the menu navigation for below is still showing the parent as hidden link

hidden link

So any breadcrumb system would not show the correct path. So it should be more like this original path hidden link

Thanks
Simon

Frédéric GILLES posted 02/05/2018 20:14
For that, I can't do anything.
You should contact the Toolset team to ask them if they have a solution to your request.

#789483

I need the nav like this hidden link;
As I said before, this type of permalink structure is not supported by Toolset. I cannot provide you with a solution to accomplish what you're asking for. I cannot debug another person's custom permalink structure code here either. I can help you if there is a problem in the standard permalink structure, but not with a hierarchical structure like this.