Skip Navigation

[Closed] Issue Connecting 2 Custom Post Types in 1 Content Template

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

Last updated by Minesh 1 year, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2583793
CPT snipping example.PNG

Tell us what you are trying to do? I have 2 custom post types (Series, Pictures). The relationship between the post types is that many different digital art pictures can be a part of a series, but each picture can only have 1 series, which basically describes a 1-to-many relationship. I've created a Content Template to be used so that whenever someone wants to view one of the pictures, the content template will be used. In the template, I would like a statement that mentions which picture in the series they are viewing. ie: Picture 3 of 9. Now, the "picture 3" part of that statement comes from a custom field for the "pictures" post type. The "of 9" part of the example comes from a custom field for the "series" post type. However, when I try to include both of the parts into the content template, the statement only displays the part that comes from the "pictures" post type (ie: Picture 3 of [blank]). It never displays the "9"). I tried doing this same thing in a View, and I get the same result.

I currently have a 1-to-many relationship used between these 2 post types, so I figured that would have allowed this to work. Please let me know what I'm doing wrong. Thanks so much.

Is there any documentation that you are following? No.

Is there a similar example that we can see? n/a

What is the link to your site? pt.onesparkdev.com

#2584031

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi there

The context where you are displaying field values is a picture, which is a child of a series.

If you use the Field and Views button to insert the shortcode to output a field, by default it will get the value from the current post (either the single post being displayed, or the current post in the loop of a View).

But you can also specify an alternate source (you should see that option in a tab on the left of the dialog to insert the shortcode), and in this case you would be able to specify that you want the source to be the parent series post. Try it and see.

The resulting shortcode has an item attribute added which specifies the different source.

(Note this works when there is no ambiguity about post you would be referring to. In this case you are referring to the parent, of which there can be only one. It doesn't work in the reverse direction, because a series could be referring to one of any number of child posts, and in that case you would have to use a View to display the children of the parent.)

#2584453

Does this work for Content Templates, or just Views?

#2585673

Minesh
Supporter

Languages: English (English )

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

Yes - you can display the parent and child both using views and content template but if you want to display many Childs belongs to single parent then you will require a view to get all related (many) child posts.

Can you please share problem URL where you want to display that information using content template and admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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.

The topic ‘[Closed] Issue Connecting 2 Custom Post Types in 1 Content Template’ is closed to new replies.