Skip Navigation

[Resolved] Split: showing the list of related posts and the button to disconnect them

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

Problem:

The customer asked how to create a list of related posts, along with the button to disconnect an individual relationship connection.

Solution:

Suggested to create a view to show the related posts and include the "cred-delete-relationship" shortcode in the loop to show a disconnect button.

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred-delete-relationship

This support ticket is created 3 years, 1 month 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/Karachi (GMT+05:00)

This topic contains 10 replies, has 2 voices.

Last updated by Alok Sharma 3 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2224663

Thank you for clearing out all the doubts. As suggested, I am working on both the approaches to see which one best meets the requirements.

Moving to the next issue. On the Edit Profile page, I would like to display a list of WP Themes & Plugins the user has associated themselves with, along with a button to disconnect the respective WP Theme or Plugin. In this case, I am using WP Themes & WP Plugins CPT's.

Can you please guide me here?

#2224687

Hi,

Thanks for asking.

On the user profile page, you'll create two views.

First to show the "Themes" posts, related to the current "User Profile" post, and the second one, to show the "Plugins" posts, related to the current "User Profile" post.

Inside the loop of these views, you can use the "cred-delete-relationship" shortcode, to show a button to disconnect a certain theme or plugin:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred-delete-relationship


[cred-delete-relationship role_items='$fromViews' relationship='{relationship-slug}' redirect='self' type='button']Remove[/cred-delete-relationship]

Note: You'll replace "{relationship-slug}" with the actual relationship slug, whose association/connection, you want to remove.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2226959

Hi Waqar,

I inserted the above code (after replacing the relationship slug) in the view loop, but the button is not showing up.

I tried adding the shortcode using both Shortcode and Fields & Views (HTML) block, and also tried clearing the cache but no good.

#2227387

The shortcode "cred-delete-relationship" is a part of the Toolset Forms plugin, so please make sure that it is active on the website.

In case the issue still persists, you're welcome to share temporary admin login details, along with the link to page, where this view can be seen.

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

#2227721

Thank you for sharing these details.

The view "Devsigners WP Themes" in the content template was set to show the intermediary post when it should be showing the "WP Themes" posts, related to the current post in the loop (i.e. Devsigner), with respect to the "Devsigners WP Themes" relationship.

I've updated this view's content selection and query filter settings accordingly and the delete relationship buttons are showing now.

Important note: On your website, changes seem to take a long time to start showing on the front-end due to cache. Not sure if it is at the server level or at CDN (Cloudflare), but, this delay can lead to confusion while the website is in development making you think that your changes are not working as expected.

#2227831

Hi Waqar,

Thank you pointing out my mistake and also correcting the same.

As for the other issue, thank you for bringing it to my attention. I will look into it.

My issue is resolved now. Thank you!

#2227961

Hi Waqar,

I encountered a problem with WP Plugins Views in the same content template. Instead of displaying the WP Plugins, the current username is being displayed.

In WP Plugins Views block, for the Single Field block, the only options available in Post Source dropdown are Current Post & Other Post.

Whereas for WP Themes Views block, for the Single Field block, available options in Post Source dropdown are Current WP Themes & Other Post.

I believe this is why the username is being displayed.

I am unable to figure out why this is happening. I tried to disconnect & reconnect WP Plugins with the associated user and also created a new view but still the same thing.

Can you please check and let me know what could be wrong?

Thanks in advance.

#2228651

I've checked and the view for the "WP Plugins" post is configured correctly.

Yesterday, while investigating, the view for the "WP Themes", I was having the same issue. It was showing the "Devsigners" post instead of the "WP Themes" posts, but after a while and without any further changes, it started showing the correct post type.
( that is why I included the note about the cache in my last reply )

I'll recommend testing this with a default theme ( like Twenty Twenty-One ) and with all non-Toolset plugins disabled. It would also be interesting to test this on a different server and without Cloudflare, to rule out any cache issue/conflict.

Important note: Blocks-based views don't officially support nesting and in your required setup, you need to nest items into each other to change the current post's scope repeatedly. It starts from the page "My Profile", in which a content template "Devsigner Profile" is loaded to change the current post's scope to the current user's "Devsigners" post. Next, you need two separate views to change the current post's scope to "WP Themes" and "WP Plugins" respectively, and both views need to have a post-relationship filter with respect to the current "Devsigners" post.

For this reason, it would be better to use the classic/legacy views instead of the blocks-based views in the template "Devsigner Profile" for showing the related themes and plugins.

You can go to WP Admin > Toolset > Settings > General and select the option "Show both the legacy and Blocks interface and let me choose which to use for each item I build" for the editing experience.

After that, you'll see the option to create classic views from WP Admin > Toolset > Views.

Using classic/legacy views, you'll have the ability to pass on the current "Devsigner Profile" post's ID in the view's shortcode attribute to use for the relationship filter in the views for the themes and plugins.
( ref: https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/#filter-by-post-relationships )

Note: I'll be on vacation so won't be able to follow up on this ticket till Monday. So for more timely assistance, I'll recommend starting a new ticket for any new questions or concerns.

#2228737

Hi Waqar,

Thank you so much for the guidance. I went ahead and enabled “Show both the legacy and Blocks interface and let me choose which to use for each item I build”.

Then I created views for WP Themes & WP Plugins and added them in the content template. It is working perfectly fine now.

Using classic/legacy views, you'll have the ability to pass on the current "Devsigner Profile" post's ID in the view's shortcode attribute to use for the relationship filter in the views for the themes and plugins.
( ref: https://toolset.com/documentation/legacy-features/views-plugin/passing-arguments-to-views/#filter-by-post-relationships )

I couldn't understand this as I selected “The current post in the loop” option, and it is working fine. You may want to have a look at it one last time to see if this is how it was supposed to be set up.

P.S. While you are on holiday, I will take care of other things. You may reply once you are back from your holiday. Have a wonderful time. 🙂

#2229555

Thank you for your kind words and glad that my suggestions helped.

When you're using a classic/legacy view inside the loop of another view “The current post in the loop” option would work just fine. You can make a note for the future, that the 'shortcode attribute' option is something that can be used for cases, where you need to show the related posts, not from within the loop of another view, but you have the ID of the target post.

You're welcome to mark this ticket as resolved and start a new one for any further assistance.

#2229583

My issue is resolved now. Thank you!