Skip Navigation

[Resolved] Creating a dynamic link to show related posts

This support ticket is created 2 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.

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 11 replies, has 2 voices.

Last updated by Alok Sharma 2 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2243273

Hi,

I would like to create a dynamic link which would show all the related posts in a relationship but not on the current page.

For, e.g., displaying all the Plugins related to Devsigner. Ideally, it would not make any sense to display all the plugins related to devsigner on devsigner's profile page. So I would only show the first five or ten plugins on the devsigner's profile page and place a link "View all plugins". This link would then show all the plugins related to devsigner.

Similarly, displaying all the themes related to Devsigner.

I did come across an article, but it does not have a working example and hence I am confused if I have to create a single view or multiple views and how to create a dynamic link which will pass the necessary parameters which would display theme / plugins related to current devsigner.

Thanks.

#2243429

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Basically, the following tutorial or Doc shows how you can display related items on the current post.
=> https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

To display all related items on different page, you will require to create a new page where you want to display all related Plugins or theme and we will require to pass the related post ID and the entity (plugins/theme). But I will be able to guide you once I review your structure.

If you can tell me where exactly one what post/pate (please share link of those) you want to display what and once I review your post relationship I'll be able to guide you in the right direction.

*** 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 have set the next reply to private which means only you and I have access to it.

#2244071

Minesh
Supporter

Languages: English (English )

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

It seems you are working on this currently and I can see you added theme or plugins are belongs to "Alok Sharma":
=> hidden link

If its not resolved yet, can you please tell me what heading you want to place where at what section of the page?

#2245083

Hi Minesh,

The method that I adopted utilizes the existing archive template for theme, plugin & portfolio. However, it also requires that I place a post relationship filter in the respective archive templates, or else the devsigner ID parameter passed to the archive template does not filter the posts.

I went ahead with your other suggestion and created a page, "Devsigner's Preferred Themes" (Page ID: 110) and also created a view. On the top of this page, I would like to display a heading "<Devsigner>'s Preferred Themes" where <Devsigner> would be replaced with the actual name of the Devsigner.

However, I would prefer to display the above-mentioned heading on the archive template instead of creating a separate page, as it would difficult to manage so many pages & views at a later stage. For this, I plan to use the condition block to check is wpv-relationship-filter[] parameter is empty or not. If it is not empty, then a heading would be displayed. But I am unable to figure out how to get to it.

#2245127

Minesh
Supporter

Languages: English (English )

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

Can you please tell me where exactly you are trying to add the conditional block? on what page/post/archive?

#2245195

Hi Minesh,

Sorry if I was not clear. It would be:

"Devsigner's Preferred Themes" (Page ID: 110)

and

Archive for Devsigner

#2245201

Minesh
Supporter

Languages: English (English )

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

I'm bit confuse as with your previous reply you told me that you want to use page as I suggested and in next paragraph you shared that you want to use archive.

I'm on this page now: hidden link

Could you please clarify what exactly you want to add on above page?

#2245361

Hi Minesh,

Sorry once again if I am not able to explain properly.

You are on the correct page. If you notice, I have added Fields & Views block somewhere in the Search or Loop section. In this block, I am trying to display the Devsigner name (Post Title) for which all the themes are being currently displayed, but it is not working.

#2245923

Minesh
Supporter

Languages: English (English )

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

So, for instance, lets take example of the "Astra" theme:
=> hidden link

So, on this page: hidden link
- With "Astra" theme, you want to display all related Devsigner names that is "Alok Sharma", "Devsigner 02" and "Devsigner 04"

Is that correct? If yes:

I see you are using many-to-many post relationship between post type Devsigners and Themes. So, to display all related posts of single parent/child of many-to-many post relationship, you will require to create a view.

Can you please confirm first that my understanding is correct and then I'll share the solution.

#2246273

Hi Minesh,

The site uses a lot of relationships, and all the CPT's are interconnected with each other.

If you visit this page hidden link and then click View all link below preferred themes, you will be taken to hidden link

On this page, I would just like to show the Devsigner's name as the heading, which would be Alok Sharma. To show the devsigner's name, I added Fields & Views block and entered [wpv-post-link item="@devsigner-theme.parent"]. I placed this block inside the View block. The problem is that it does display my name, but not on the front-end, only when editing the page.

#2246735

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've changed the URL param from wpv-relationship-filter[] to wpv-relationship-filter. Where I removed the [] brackets from the URL param.

Now, when you click on the "View ALL" link: hidden link
- It will redirect you on the following page:
- hidden link

And I can see "Alok Sharma" is displayed and that is displayed using the following shortcode:
=> hidden link

[wpv-post-link item="[wpv-search-term param='wpv-relationship-filter']"]
#2247129

My issue is resolved now. Thank you!