This thread is resolved. Here is a description of the problem and solution.
Problem:
Client wants to store related posts in a custom field and to then be able to output content of those related posts when viewing the first post (a simple bespoke solution that doesn't involve post relationshipts).
Solution:
Store the related post IDs in repeating numeric fields, i.e. add as many as there are related posts.
Then in the Content Template for this post type, to display content from the related posts use the wpv-for-each shortcode to loop over the numeric fields which store the post IDs which can then be used as the id attribute of the shortcodes used to output the required fields.
Tell us what you are trying to do? we need to allow for each custom post to create a grid of related posts by selecting manually the URL of each post and display them in a grid element with thumbnail, title and link.
We know that in your beta version of new release it will be available a "related post" field but how can we build that feature in the meantime with the existing tools?
What is the link to your site? the page where the grid shall be displayed is this: hidden link in the NEWS tab content.
If you are connecting posts of the same type, I would create a repeating numeric field which stores the ID is related posts.
So when you are editing one post you can add as many related-id fields to that post as you like.
Then in the content template for a post, where you want to display the related posts you can use the wpv-for-each shortcode to loop over the related-id fields. You will be able to use this field for the id attribute of the Views shortcodes to output the title, the image, and to create a link.
Hi Nigel,
i need some help with the view structure because I am not able to define the query filter of only the post ID that are recalled in the custom post.
Do you have any code example?
In the layout I created the following code that recalls the view data but it doesn't work because I don't find where in the view I can say that the filter shall consider only the ID that are stored in the "related-posts" field
Say I have a post type of "projects" and a repeating numeric field of "related-posts".
I create a template to display projects (either a Views Content Template, or a Layouts template), and then I add code such as the following to output the related posts:
[wpv-for-each field="wpcf-related-posts"]
[wpv-post-title id="[types field='related-posts']"] <-- output post title of a related post -->
[wpv-post-featured-image id="[types field='related-posts']"] <!-- output featured image of a related post -->
[/wpv-for-each]
That will loop over each of the related post fields and output content from the related post itself, by using the id attribute to switch context from the current post to the target post. You can use this to output any field from the related posts.