Skip Navigation

[Resolved] Get id from intermediate post

This thread is resolved. Here is a description of the problem and solution.

Problem:

Get related intermediate post IDs by many-to-many relationship.

Solution:

You can follow our document to query the intermediate posts:

Relevant Documentation:

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

This support ticket is created 5 years 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by Rickard 5 years ago.

Assisted by: Luo Yang.

Author
Posts
#1502525
intermediate-post.png

I am trying to:

I have two post types: Posts and Facts

In posts I want to use WP-PostRatings to store the votes for the relationship.

Therefore I tried to use the blocks editor to enter the post id of the intermediate post into the ratings shortcode.

However I could not select it and I only get the post id for the Facts post type

I then tried to edit the html and entered the slug of the intermediate post type as id="$slug-og-post-type"

[ratings id="[wpv-post-id id='$post-fact']"]

Stil only get the id of the facts post type entry.

My question is: How do I get the id of the intermediate post? I am using Toolset Blocks

#1502859

Hello,

I assume we are talking about many-to-many relationship:
- One post can connect to multiple Fact posts
- One Fact post can connect to multiple posts

If it is, one Posts/Fact posts can have multiple intermediate posts, you can follow our document to query the intermediate posts:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

Section "Displaying many related items"

#1503171

I tried as you suggested to make a view that fetches the id.

The problem I ran into now is that the view output is not "raw".. It adds alot of html.

Found in this post: https://toolset.com/forums/topic/values-between-views/

"Toolset Views cannot be used to produce a clean Loop output (Data providing), but is only inteded to be used to display data, as such, it has some default HTML around every Loop, and that will make it impossible to compare "raw" values."

The recommended solution was there to skip toolset and make a custom shortcode that outputs the value.

Is this still the suggested solution and if so do you have a suggestion how I should code it?

I guess the new shortcode need to get as input the slug of the post type to fetch the id from. And the slug of both connected post types and the ids of the connected posts? Then fetch the post and output the id..

#1503177

Please edit your post view, in section "Loop Editor", find and enable option "Disable the wrapping DIV around the View", and test again.


Normally, the View has a wrapper DIV which includes IDs and classes required for AJAX updates and pagination. If you want to show the View inline with text, you can disable this DIV, but you will not be able to use some of the functionality that Views offer.

#1503231
loop editor in block editor.png

Im having problem finding this option in the block editor. I send a screenshot here with the options that is in the block editor for the loop.

Cant find a way to edit the view in toolset admin or outside of a post that has the view as a block.

#1504461

Yes, you are using Blocks to create the new view, that option is not available in the view block yet, it is under development., but it is availiable in lagacy view.

Please try these:
1) Dashboard-> Toolset-> Settings-> General
in section "Editing experience", enable option "Show both the legacy and Blocks interface and let me choose which to use for each item I build"

2) Dashboard-> Toolset-> Views
Create a new view, you will see the option as I mentioned above
https://toolset.com/forums/topic/get-id-from-intermediate-post/#post-1503177

#1507969

My issue is resolved now. Thank you!

I also tested a solution where i made a "block view" with the intermediary posts then from that list fetched the content from the facts post type. Then it also worked without making a "classic view"