Skip Navigation

[Geschlossen] Types + Views Many to Many Help

This support ticket is created vor 7 Jahre, 6 Monate. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 19 Antworten, has 2 Stimmen.

Last updated by Nigel vor 7 Jahre, 4 Monate.

Assisted by: Nigel.

Author
Artikel
#445901

I am trying to:

I have 3 custom post types created with WP Types

1) Workouts
2) Rests
3) Recipes

I have followed the info on https://toolset.com/documentation/user-guides/getting-started-views/part-9-many-many-relationships/ to create a 4th post type "connector" instead of the example "appearance" so I can connect specific posts from the various 3 post types to show related posts.

My idea then is that on the single post view for a workout I will have 3 sections at the end...

1) Related Workouts
2) Related Recipes
3) Related Rests

So the three post types have synergy.

I visited this URL:
hidden link

I expected to see:
The output of 1 recipe under related recipes and 1 rest under related rests.

Instead, I got:
For some reason it outputs and displays the connectors.

I basically want to have 3 lists of 3 posts...

So show 3 related workouts (this works as I am using the category query as it is the current post type), 3 releated rests from the rests post type and 3 related recipes.

Any ideas where I may have gone wrong?

#446085

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Hi David

Without going into too much detail of the particulars of your set up, your observation that "For some reason it outputs and displays the connectors" suggests you are half way to the solution.

Your query needs to return the connector posts, but in the loop output section you want to output content not from the connector but from the parent post, which you do by adding the id attribute to the shortcode.

Read more about that here: https://toolset.com/documentation/user-guides/many-to-many-post-relationship/#4

and here: https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

So if your recipes have a slug of 'recipe' and you have a view which queries the intermediate child post then in your loop output section to display the title of the recipe you would use [wpv-post-title id="$recipe"].

There will be a major overhaul of how many-to-many relationships work in the next version of Views which will make all of this much easier. You can read more about the upcoming changes here: https://toolset.com/2016/08/how-post-relationship-replaces-post-reference-and-repeating-fields/

#446431
tCapture.PNG
lCapture.PNG

Hi Neil,

Thanks for your reply.

That is odd, I have already done what you suggested. If you see the screenshots in my template for this view I have each shortcode with the $recipe id set however it shows a recipe and a connector on hidden link

Also I have another view which does the same for $rests however that outputs 2 connectors but no rests.

This is a production site so I can happily share the login with you if you want to take a look.

Essentially there are 6 views. 3 for each post type to show in the many by many approach, and 3 views which show the current post type by category (which is how I show related workouts and that one works) on hidden link

If you edit the view "Related Recipes" you will see the one we are looking at first.

When is the overhaul / next version scheduled for release roughly?

Thanks for your help.

#446434

Do I need to stipulate the post type ID in the loop part?

With the new updates to many to many in 2.3 would it always be parent/child? I wonder because my 3 post types are all more like siblings than in any parent/child hierarchy? Just wondering if that will have any negative impact.

#446555

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Hi David

Let me run through this step-by-step to see if you can see where you may have done something differently.

You have 3 CPTs to connect, Workouts, Recipes, and Rests.

You create a Connector post type to server as an intermediary between your 3 main CPTs and you specify that the Connector post type is a child of Workouts, Recipes, and Rests.

You make some actual content and join it with the connector.

Say for Workout A there is a related Recipe 1 and a related Rest alpha.

To connect A to 1 you publish a new Connector A1 where you add A and 1 as post parents.

To connect A to alpha you publish a new Connector Aalpha where you add A and alpha as post parents.

If you also wanted to connect the Recipe 1 and Rest alpha you would also publish a new Connector 1alpha where you add 1 and alpha as post parents.

Now you have some sample data.

Let's say we want to display a single Workout (A) and on that page also list related Recipes.

So we would create a Content Template for Single Workout Posts, which will be used whenever we view a single workout. We design the content as we like with views shortcodes to include the main post body and possibly some Workout custom fields, and then we also add a shortcode for the View which will display the related Recipes.

This is how that View works.

The content that this view will display are Connectors.

We only want Connectors for the single Workout we are currently displaying via the above Content Template, so we add a query filter to only show posts that are children of the current post in the loop.

So if we are viewing Workout A then this View is going to retrieve Connectors that are child posts of A.

Then in the Loop Output section we link to a Content Template which outputs the content not of the Connector but of the parent Recipe(s), using the id="$recipe" attribute. (Like you have in your screenshot.)

That's it.

If you follow the steps above it should work. I suspect your issues may be in creating the connected posts in the first place.

Let me know how this compares to what you have done.

As for the timetable for the many-to-many post relationships changes, we are already in to mid-October, so I would hesitate to say anything more specific than this year. (It is a major project.)

#446809

Thanks for the detailed response Neil. That does however seem to match up with what I have done. There isn't anything there that looks different to what I have done.

As it is a development site could I send you a login so you can just look at the edit workout screen and look at the connectors at the bottom? and at the connectors that were automatically created from the edit workout screen that then exist under the connectors post type in WP?

Thanks

#447417

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Hi David

Let me take a look.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes.

#448559

Hi Nigel,

Thank you. The login for this site isn't precious so I will share using the form below, I have taken an updraft backup.

One thing to note. Maybe keep an eye or wait to see an update on https://toolset.com/forums/topic/wp-views-beaver-builders-integration-1-issue/ where I am tracking/reporting another issue I noticed with the new Toolset+Beaver Builder functionality when it comes to using a conditional statement to see if the beaver builder class is active on a page. May be of interest to you but basically might be worth checking with Luo if you can internally to see if/when he is looking at that other issue so you don't have an overlap issue etc / bump heads digitally ;).

Is that okay? You can of course login and look and see what jumps out to you in the meantime.

Do you want to activate the form so I can fill in the FTP and WP admin details there? can't see the option yet on this reply.

Thanks, appreciate your help. Love Toolset! 🙂

#448752

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Sorry David

I must have missed checking the private box. Let me try again.

#449178

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Hi David

You hadn't created the connector posts required to join workouts to their related content.

Here you will see that related recipes works for Test Entry 7: hidden link

If you check the connector posts you will see that I published connectors for that workout to each of the related recipes.

It is somewhat cumbersome but will become easier and more intuitive in the Types update which overhauls many-to-many relationships and will mean you don't need to publish connector posts.

#449332

Okay so when you create a connection on the edit recipe or workout page that isn't sufficient? you have to actually go to connections on the dashboard and create those manually first? one for every connection point? Yes that is not very intuitive at all. I need to launch this in the next 6 weeks or so, any idea if we will be close to the new version by then?

Thanks for your help Nigel.

#449643

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Yes, David, you need to create the connections manually.

There are 3 ways something like related posts can be handled.

- You can manually set which posts are related to which other posts. Currently in Types you do so with intermediate posts. In the upcoming version it will be different, but you will still have to manually make the connections.

- You can loosely connect them (e.g. via a taxonomy) and show 3 random posts from the matching set

- Or you can develop some kind of algorithm to determine which posts are connected

Which method you use will trade off relevancy for ease of use. The first option guarantees relevancy but is more time consuming, the second is easy but less relevant.

And the third option would require a custom solution which would involve a lot of up-front development effort but may yield pretty relevant results.

#451567

I am away in St Lucia at the moment and back in a few days and will check through this and test then. Can we keep the thread open until I have had chance to have a proper look?

Thanks

#454106

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Hi David

I'm back after a couple of days off myself, just posting here to keep the thread ticking over in case you need a little longer with any follow-up question.

#458863

Hi Nigel,

Thanks for doing that, has been a busy month since being back.

I went back over there and tested it again following your instructions but still get unexpected results. For instance, I got the recipes working by repeating the steps, BUT when I then go and make connectors for Rests it doesn't work and also impacts the recipe set in the same position. So if I change the first related rest the first related recipe above it breaks.

See: hidden link

but I don't understand the logic of this error.

I guess a month has passed so was also wondering if there is any news on the new version / update which simplifies this many to many process?

Also I was wondering, if it isn't too much trouble, perhaps to save time on the above going back and forth we could maybe use skype and screenshare to go through the process and iron out the kinks? Totally understand if that isn't possible but would be greatly appreciated.

Hope you have had a good month Nigel.

Thanks again.

Das Thema „[Geschlossen] Types + Views Many to Many Help“ ist für neue Antworten geschlossen.