I've created a custom post type "Drama" with custom fields (ie. synopsis, network info).
I have another custom type "Downloads" that was created with another plugin (WordPress Download Manager).
These 2 types are associated via a relationship.
I'm able to show sections from "Downloads" on the "Drama" post, but I have no idea how to show "Drama" content on the "Downloads" post.
I've tried using Toolset shortcodes from the Content templates and Views inside the WordPress Download Manager templates, but they are not showing. I think PHP code will show though.
Hi, in general I would use a View of related Drama posts to display Drama post information. You can use PHP to insert that View in a Download single post. Here's how I would set it up:
- Create a new View of Drama posts. In the Query Filter section, add a post relationship filter. Select your Drama / Downloads relationship and configure it so that the Drama posts are related to the post where the View is shown (which will be a Download post).
- In the Loop Editor, create a loop that displays information about each Drama post using Toolset shortcodes. Choose any loop format you want, and add your own custom HTML and CSS to style the results.
- Insert this View in your custom PHP template for Download posts using the render_view API: https://toolset.com/documentation/programmer-reference/views-api/#render_view
$drama_args = array(
'id' => 12345,
);
echo render_view( $drama_args );
Replace 12345 with the numeric ID of the View of related Drama posts. You can find that ID in Toolset > Views.
Thanks for providing the steps for this Christian!
So I followed the above steps and noticed that the php snippet didn't work.
I tried using the short code for the view instead [wpv views] inside the "Downloads" template and now the associated content is loading!
I've figured out most of it so far, but I've stumbled upon another issue which is related to this.
I'm trying to list the related "people" type from the "drama" type in the view on the "downloads" page, but it's only showing the first person associated. I realize that I need some loop, but I'm having troubles figuring that out.
Here's the code that I have:
- Title (romanized): [wpv-post-link]
- [types field='episodes' format='FIELD_NAME: FIELD_VALUE'][/types]
- [wpv-post-link item="@cast.child"]
- [wpv-view name="list-of-credits"]
- [su_expand more_text="Show more" less_text="Show less" height="100" hide_less="no" text_color="#333333" link_color="#0088FF" link_style="default" link_align="left" more_icon="" less_icon="" class=""][types field='synopsis'][/types][/su_expand]
- Genre: [wpv-post-taxonomy type="genre"]
.
Are you referring to the wpv-post-link shortcode that displays Sawamura Ikki? A single wpv-post-link shortcode cannot display multiple results. You must create another nested View. You've already done this once, so it should be familiar to you already. The post relationships will be different and the content selection will be People posts, but the process is similar. Then replace the wpv-post-link shortcode with the new View shortcode.
Yes, I'm referring to wpv-post-link shortcode that displays "Sawamura Ikki".
Thanks for pointing me in the right direction, I wanted to make sure before I started to implement another view.
Will try it now and let you know!
Thank you!!
I had to switch and play around with the settings in the Views to get what I finally needed.
Thanks!
My issue is resolved now. Thank you!