[Resolved] Many to Many CPTs + View + Content Template Reference Not Working as Expected
This support ticket is created 6 years, 11 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.
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.
I have 3 CPTs configured in a many-to-many Post Relationship: People, Relations (for recommendations), Books.
Relations has two parents: People & Books.
The idea is that Book pages show People that recommended them, and Person pages show Books they recommend.
I configured a View:
Content Relation: Relations
Query Filter: Select posts that are children of the Post where this View is shown.
- Note: I have also tried this without this filter.
I created a content template (I am using Divi): (See image: 2017-11-30_21-13-05.png)
{!{wpv-post-featured-image id="$person"}!} <--- That links to {!{wpv-post-url id="$person"}!}
{!{wpv-post-url id="$person"}!} <--- this is simply a "control" to show the problem. This is used for the image above.
{!{wpv-post-link id="$person"}!}
The EXPECTED output is:
<Image> that links to Parent $person
<post url of the Parent $person>
<post title of the Parent $person> that links to Parent $person
The ACTUAL output is funky: (See image: 2017-11-30_21-14-53.png)
<image of parent $person> <-- image display correctly, but links INCORRECTLY to the relation-xxx post
<shows text URL of the correct Parent #person> <-- This is odd because this is what the image link should be. It shows renders correctly here, but incorrectly as a link on the image above
<shows post title + link with the correct Parent $person>
Hello. Thank you for contacting the Toolset support.
Well - You configured your view as:
Content Relation: Relations
Query Filter: Select posts that are children of the Post where this View is shown.
But you said that "Relations" has two parents: People & Books. That means, the view you setup above is incorrect as "Relations" has no child but "Relations" itself is a child post.
I can better tell you once I can look at your configuration.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
First of all, sorry for inconvenience as you think asking access details causing issue for you but this is the best way we can fix the thing and you will know why it is important because it can be any silly mistake.
I checked the code and I see the culprit.
I checked that you wanted to display associated person information and you setup many to many. Whatever filter you used is correct now (I came to know after checking your setup) because Book is parent and we are querying its child (Relations) from parent post page.
Now, see the important of asking access details.
Your code was wrong (I deleted it) - as you can see double quotes translated to html entities that is why it was not showing the issue.:
Please check following screenshot: hidden link
And I can see its displaying correct person URL now. Could you please confirm.
I see you are editing the content template now... and I ~~think~~ i finally found the problem.
When trying to link the featured image... the shortcodes or curly-brackets result in nested " quotes within the html tags.
So, this code:
<a href="{!{wpv-post-url id="$book"}!}"></a>
... is rendered as the following when using the Visual Editor:
<a href="{!{wpv-post-url id="$book "}!}"></a>
... another funky behavior when switching between the Visual Editor & Text is the code will render as with an odd space before the $variable and append ="":
<a href="{!{wpv-post-url id=" $book"}!}"=""></a>
... the easy and simply fix is to use single quotes:
<a href="{!{wpv-post-url id='$book'}!}"></a>
I have spent DAYS trying to solve this 🙁 . I was "asking the wrong questions" in my forum searches, and this issue isn't referenced anywhere in the documentation that I could find.
Yes - you found the culprit as shown in the screenshot.
=> hidden link
The code you sent is not rendering on forum page, so I do not see it. We already reported that to our developers.
As your original issue is resolved. Please kindly open a new ticket with your each new question.
Also, when you try to share code, please use google doc and add your sample code to it as currently we have issue rendering the code you added forum reply.