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.
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.)
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.