I am busy working on an auction companies catalogue for their previous auctions.
I have 4 custom post types:
1) Sale
2) Session (parent: Sale)
3) Lot (Parent: Sale, Session)
4) Category ( I might change this to a custom taxonomy for Lot)
Step one:
Add new sale
Custom fields for sale include:
Sale Name
Sale Number
Location
Start Date
End Date
Step two:
Create new lot
Custom fields pictured below:
hidden link
beneath that field it asks me to enter the sale information:
hidden link
How do i make it that this data is populated by selecting the parent from a drop down box like it is in the real estate site demo:
hidden link
I am happy to supply admin login if you need to look first hand.
Regards.
Josh
Update:
I was able to finally figure out that the reason I wasn't able to save Auction Lots was because the parent categories' fields were marked as required.
However, even though i am now able to map the relationship between the Auction lot and the parents (Sale and Session) the box for "Sale Data" which is a CPT Custo Field is still showing up, and is unpopulated.
Because the relationship is set, the data will be displayed in the view, however i am would like to know why the box is there: hidden link
Thank you for contacting Toolset support, I'd be delighted to assist!
I'm happy you got it figured out! I'm the only supporter in this timezone so I'm usually putting out several fires so I appreciate your patience with me 🙂
The 3rd box renders on the backend due to the way Toolset works, Parent fields will render in children so there is the possibility of it being entered for if a use case would require it. Apart from hiding it via CSS, I would recommend ignoring it.
Does that help, did I miss anything or am I off base?
HI Ross.
Thank for your reply.
I am ok with the box being there, however the problem is the data is not pulling through from it's parent.
Here is a screenshot of the Edit Auction Lot:
hidden link
You can see that the post relationship is set, however the "Sale Data" from the Sale CPT is not pulling through in the Edit screen, nor is it pulling through on the Single post of the Lot as seen below:
hidden link
The code for the view is simple as I havent started styling yet as I want to get this right first:
[types field="image" size="medium" align="none" resize="crop"][/types]
<p>[types field="write-up"][/types]</p>
<div>Sale Name: [types field="sale-name"][/types]</div>
<div>Auction Location: [types field="location"][/types]</div>
<div>Session: [types field="session-name"][/types]</div>
<div>Date: [types field="start-date"][/types] - [types field="end-date"][/types]</div>
<div>Dimensions: [types field="dimensions"][/types]</div>
<div>Condition: [types field="condition"][/types]</div>
<div>[types field="low-estimate" format="FIELD_NAME: FIELD_VALUE"][/types]</div>
<div>[types field="high-estimate" format="FIELD_NAME: FIELD_VALUE"][/types]</div>
<div>[types field="sold-unsold"][/types]</div>
<div>[types field="hammer-price" format="FIELD_NAME: FIELD_VALUE"][/types]</div>
Sale data is inputted in the Sale CPT:
hidden link
However is I scroll further down the page to the post relationship the same problem persists with linking Sale Data to Session Data hidden link
If I manually put the data in I am sure that it will show, however this is not an ideal solution.
You advice will be appreciated.
Josh
Question: Would it be more efficient to scrap the multiple CPT idea and just have all the required fields on the Auction Lot CPT?
It all depends on your use case! One thing is for sure, you can display the contents of the parent CPT with a specific shortcode:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
To include a field from the parent post, you would use the following shortcode:
[types field="xxxx" id="$yyyy"]
Where xxxx is the field of the parent you want to show, and yyyy is the slug-name of the parent. The “$?? is required, as this represents a variable where the parent post name will be replaced by the post ID, internally.
To auto populate a child's CPT fields from the parent's fields, you would need to write some PHP using the CRED API: https://toolset.com/documentation/user-guides/cred-api/ to pull data from parent CPT and place into child's fields.
Thank you. [types field="xxxx" id="$yyyy"] was the answer I was looking for.