Here is the background:
I am using the wprss aggregator plugin that allows me to import rss feeds.
Here is the way it works:
- each feed source is defined by the plugin as a post with the custom post type "feed sources"
- each feed item of that feed source is imported as a post with the custom post type "X"
- I have setup a "one to many" relationship between the CPT "feed sources"and the CPT "X" : a feed source (parent) will generate many feed items but one feed item (child) has only one feed source
- I have setup 2 custom fields for the CPT "feed sources" :
wpcf-wprss_custom_feed_name
wpcf-wprss_custom_website_url
My goal :
When displaying the single view of the CPT "X", I wish to display the 2 customs fields of the "parent" CPT, ie
wpcf-wprss_custom_feed_name
wpcf-wprss_custom_website_url
What I am getting:
I am able to select those 2 custom fields when designing the single view template but they do not display anything on the front end.
I have checked the postmeta table in phpMyAdmin and it turns out these 2 custom fields are properly populated.
By the way, the single post view is accessible from the home page by clicking on any image.
Once you land on the single post view, you will get access to the real name for CPT "X".
That leads me to think that the relationship between CPT "feed sources" and "X" is not setup properly.
Here is what I thought:
I have noticed there is a custom field (at least a meta key in the postmeta table) created by the plugin for the CPT "X" post whose name is wprss_feed_id
This field holds the value of the post ID for the CPT "feed sources" post (that's how we know what post item comes from what feed source)
I was assuming that the existence of that custom field/meta key was enough to be able to setup a relationship between CPT "feed sources" and CPT "X" storing the items imported by the feed sources. Obviously I might be wrong on that one.
1) Sorry for the URL. Actually, the domain is right but you have to change the extension from .com to .fr
2) The home page is a set of images (actually it is some kind of "view" generated by a shortcode of the wprss aggregator plugin itself) from CPT "X" posts. When you click on any of them, you will land on a single view page for the CPT "X", that's the place where I try to display a custom field belonging to the parent CPT "feed sources". Please note that I did a comment on that single view page to reveal the real name for CPT "X", that will help you when browsing the admin area (it begins by "G"). You can spot that single view template very easily : that's the one named "Template for G...."
I keep thinking that the relationship may not be set properly. Sure I followed the standard instruction to create that "one to many" relationship but I have to admit I do not know exactly how Toolset is able to link a parent post to a child post (besides the instructions to follow). I mean, what will be the key/custom field/data that connects one CPT to the other CPT? The other thing to keep in mind is that the CPT "feed sources" is created by the plugin, not me. I don't know if that makes a difference.
Ok, that clears things up. Actually I did not know how to connect a child to its parent and you have given me the answer.
But here is the thing : the "children posts" are created automatically by the wprss aggregator plugin (that's the import process which is the core functionality of that plugin).
In such circumstances, when you say "The posts won't be connected to a parent automatically" , I guess that means I will not be able to setup that relationship I was seeking for (because I will not update manually each and every child post). Do you confirm that?
That is correct, even though the posts are being automatically created by your aggregator plugin you still will need to manually edit each post to Connect them to a parent post.