[Resolved] Cannot output parent field in CRED child post using [cred-post-parent get=”id”]
This thread is resolved. Here is a description of the problem and solution.
Problem:
I am trying to output the value of a parent post field within a new / edit child post CRED form using [cred-post-parent get="id"] as below, but I cannot get it to work.
If your CRED form is set to work with a child post type that has more than one parent, you must use the post_type attribute. Additionally, it is not possible to get parent information from multiple parents but only one.
So you will need to setup the shortcode, like this:
2) And the shortcode [cred_post_parent] does not support shortcode within shortcode feature, you can try with another Views shortcode [wpv-search-term], for example, replace this line from:
I am trying to output the value of a parent post field within a new / edit child post CRED form using [cred-post-parent get="id"] as below, but I cannot get it to work.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Well - I do not able to access the wp-admin using the user "supportuseradmin" - could you please grant me full admin rights so that I can able to check on your install.
2) And the shortcode [cred_post_parent] does not support shortcode within shortcode feature, you can try with another Views shortcode [wpv-search-term], for example, replace this line from:
[types field="intro-line" id="[cred-post-parent get="id"]"][/types]
To:
[types field="intro-line" id="[wpv-search-term param="parent_deck-event-overviews_id"]"][/types]
I have modified your CRED form "New Deck Event", you can test the result here: hidden link
Thanks for this, I see it working on the NEW child post form now, however, the same method does not work for the EDIT child post form, I assume because there is no parent URL parameter on the edit form page.
Is possible to have a URL parameter sent through to the edit form page or do you have another way of displaying parent fields in a child post edit form?
Yes, you are right, in a single child post, you can get the parent post ID with Views shortcode:
[wpv-post-field name="_wpcf_belongs_parent-slug_id"]
in your case, the parent type slug is "deck-event-overviews"
[wpv-post-field name="_wpcf_belongs_deck-event-overviews_id"]
And get the parent post field like this:
[types field="intro-line" id='[wpv-post-field name="_wpcf_belongs_deck-event-overviews_id"]'][/types]
####################
Debug information
####################
--------------------
Original expression: ( ($(wpcf-deck-event-vessel-selection-options).id(1523)) = '3' )
--------------------
After matching 2 numeric strings into real numbers: ( ('') = 3 )
Matched '3' to 3
Given that the above says Matched '3' to 3, what could be the reason for the contents of the conditional still not showing on the front end?
I assume the original question of this thread has been resolved, please create new thread for the new question:
I need to only display a field in the child post cred form if the parent post has a field set to a certain value.
That will help other users to find the answers. thanks