Skip Navigation

[Gelöst] Created Related Posts within Same Post Type

This support ticket is created vor 2 Jahre, 8 Monate. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 Antworten, has 3 Stimmen.

Last updated by aaronM-9 vor 2 Jahre, 8 Monate.

Assisted by: Christian Cox.

Author
Artikel
#2144031

I'm trying to link one post to several other posts, but both the "post relationship" and "reference post" options do not allow you to link one post to another if they are in the same post type. Can you please recommend the best way to do this?

To add detail, some posts may have other posts that we want to reference. For example, if there is a part 1 (free) and part 2 (premium) post, we want to reference the counterpart. Similarly, if there is prerequisite reading we want them to do prior to reading a post, we want to call that out.

Thanks for any help.

- Aaron

#2144411

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

There isn't any support for self-joins currently, and there isn't really a good solution to propose.

You would need something like a custom field to store the id of the related post, meaning you would have to edit both posts and provide the id of the other post in that custom field.

Then in the template for the posts you could output the title of (or a link to) the related post using a shortcode, where you use the item attribute to point to the linked post as the source, providing the value from the custom field, something like:

[wpv-post-link item="[wpv-post-field name='wpcf-related-post']"]

That part is easy enough, it is connecting the posts that is awkward, because you need to know the IDs of the posts to connect, not a very user-friendly experience.

You could store the post title instead, and then create a custom shortcode to use in place of wpv-post-field in the above example which retrieved the post ID from the post title, but that would still involve manually entering the title (rather than selecting it) and so would be prone to error.

#2144587

Not the answer I was hoping for, but thanks nonetheless. Do you see this as being a feature Toolset would consider adding?

- Aaron

#2144595

Do you think the following "less than perfect" solution would work?

1) Create a post type called "References"
2) Create a many-to-many relationship between References and Posts
3) Create a Reference that is linked to both Posts (i.e. Post A is linked to Reference 1, but Reference 1 is linked to Post A and Post B)

Thanks.

- Aaron

#2144597

Can you tell me if the following "less than perfect" solution would work?

1) Create a post type called References
2) Create a many-to-many relationship between References and Posts
3) Link Post A to Reference 1, with Reference 1 being linked to Post A and Post B

Let me know, thanks!

- Aaron

#2144739

Do you see this as being a feature Toolset would consider adding?
I do think it would be a valuable feature. It has been suggested before but our developers have not yet decided to implement it. If you'd like to express your desire to add this feature, feel free to submit a feature request here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

Can you tell me if the following "less than perfect" solution would work?
Technically, it is possible to implement something like this. However, it is somewhat difficult to manage in wp-admin. From Post 1, you could add a relationship to an existing Reference 1 post, or create a Reference 1 post and automatically link it to Post 1. But you could not add links to Post 2 and Post 3 directly from Post 1, you would have to do that from the Reference 1 post, or from the Post 2 or Post 3 posts. It's even more difficult to manage with front-end Forms, especially if that Reference post does not already exist. It also makes displaying lists of related posts difficult because this type of filtering isn't easily accomplished in the Block Editor.

Nigel's solution is viable, as is a custom taxonomy solution. Instead of a true post relationship, apply the same taxonomy term to each pair or group of "related" Posts. Either a taxonomy-based approach or a custom field approach will make displaying lists of "related" posts more straightforward, not requiring nested Views or shortcode / custom code solutions.

I suggest setting up a sandbox site or a test environment so you can try out each approach to see the pros and cons of each possible solution. You can create a free account in our sandbox environment at https://discover-wp.com if you don't have an easily accessible test environment. We can collaborate there if you'd like.

#2147937

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.