Hi guys,
in virtual every site i build i stumble upon the same 'problem', and i was wondering if there is a better solution than the one that i use.
Suppose i create a product landing page template. The template can be used as a regular page template by the admin. The product landing page consists of several elements including a quote slider, a product image slider and a contact person. Those three elements are actually custom post types. In the ideal world the admin can connect the set of quotes, slides or a contact person directly from the landingpage itself using a post reference field. However; this fieldtype is not available since the template is not assigned to a custom post type.
My workaround is to use post ID's. So i create a field called 'Related contact person post ID' and the admin can give in the ID of the related contact person. The problem with this solution is that it's not intuitive for the average admin and it's inconsistent with other post types (since i use the post reference field in CPT's).
So my actual questions are;
- Will the post reference field be ever available for pages?
- Is there a better workaround than the one i use?
Thanks and have a good day!
- Will the post reference field be ever available for pages?
I'm not sure I understand the problem. You can currently use Post Reference Fields with Pages, just like you would use with other post types. See references.png.
1. In a Post reference field applied to some other post type, you can choose Pages as the source post type. My example on the left is a reference field in the "Books" post type, which allows you to connect a Page to a Book.
2. You can add a Post Reference custom field in the Pages post type. My example on the right allows you to connect a Book to a Page.
One thing you cannot do is use a Post Reference field in the Page post type to connect one Page to another Page. This type of self-reference or self-relationship is not currently supported.
However; this fieldtype is not available since the template is not assigned to a custom post type.
Can you give me some more information about this? I'm confused. Maybe some screen shots would help me understand.
Hi Christian,
thanks for your answer and maybe i did not explain myself well enough.
So as said i created a template called 'landing page template'. I created a fieldgroup for this template called 'landing page fields'. I assigned this field set to this template (see first screenshot). I did not assign them to the post type pages since i don't want them to display on every page i create, only on the ones where i select the 'landing page template'. Now, when i try to add a post reference field i get a message that this is not possible (see second screenshot).
I hope this makes things a bit clearer for you 🙂
Thanks!
Hi Christian!
Do you know that moment that everything falls in place and you see something you didn't see before? Well; i have that eureka moment right now. By assigning the field group to both a template and a post type (landing page template AND page) i am able to add repeatable field groups and post relations. I need to do some reverse engineering for everything we worked on in the last months ;).
Thanks for pointing me in the right direction!
Marc