Skip Navigation

[Resolved] Relation in 2nd degree info.

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 0 reply, has 1 voice.

Last updated by danielM-41 4 months, 1 week ago.

Assisted by: Minesh.

Author
Posts
#2801575

Tell us what you are trying to do?
I have 3 custom post types: coordinate, genesis and recipe.
Coordinate relates to genesis as one to many. Geneses [0 .. 1] << Coordinates [*]
Recipe relates to genesis as many to many. Recipes [*] << Recipes Geneses >> Geneses [*]

I want to show in the Coordinates template, a list of Recipes.
I can't configure the view to filter Recipes by the parent Genesis of Coordinate.
It is also not possible to have nested views.

Is there any documentation that you are following?
I saw several lessons and searched the forum but almost everything is simpler.

Is there a similar example that we can see?
My problem is really similar to this https://toolset.com/forums/topic/show-second-relationship-info/
I prefer to configure everything with the block editor if possible but I tried with the shortcodes in that theread and I could not achieve it anywway.

Thank you,

#2801615

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and tell me what Coordinates single post you want to display the related Recipes that is connected to parent Geneses.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2801664

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

With the view block you added on your content template:
=> hidden link

As you can see with the following screenshot:
- hidden link

I've adjusted the view to query the intermediary post type "Recipes Geneses Intermediary Posts" and added the Query Filter for post relationship and set it to "Specific:"

Now, the "Specific:" will be the dyanamic value and that is hooked in using the view's hook "wpv_view_settings" that is added to "Custom Code" section:
=> hidden link

add_filter( 'wpv_view_settings', 'func_hookin_grand_parent_value', 10, 2 );
  function func_hookin_grand_parent_value( $view_settings, $view_id ) {
  global $post;
    if ( $view_id == 72 ) { 
      
       $parent_id = toolset_get_related_post($post->ID,'coordinate-genesis');
       $view_settings['post_relationship_id']=$parent_id;
      
  
         
    }
    return $view_settings;
}

More info:
- More info:
- https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
- https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

#2801681
wp-error.png

Hi,
I see the page shows the view now, but the backend is broken.
Do you know what can be causing this?

#2801707

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've removed the view block and the code added to "Custom Code" section.

Its better to use the classic view as this will also facilitate using nested view if required. So, I've created the following view in legacy mode:
=> hidden link

With above view I've added the Query Filter - to filter view results using the post-relationship filter with the view's shortcode attribute "wpvrelatedto":

Filter by post relationship or repeatable fields group owner
Select posts in a Recipes Geneses relationship that are related to the Post with ID set by the shortcode attribute wpvrelatedto.
eg. [wpv-view name="view-name" wpvrelatedto="123"]

You can adjust the "Loop Editor" section as required to display whatever content you want to display.

And I've added that view to your content template using the "Fields and Text" block as given under:
=> hidden link

[wpv-view name="display-grand-parent-receipe" wpvrelatedto="[wpv-post-id item='@coordinate-genesis.parent']"]

Can you please confirm it works as expected.

#2801714

This could be improved as I can't edit the template for recipes in the Coordinate Template directly.