I would like to add the shortcodes in the title tag of the site. For that I use yoast seo.
For simple shortcodes this works, but for a parent relationship it doesn't.
For example for the shotcode: [types field = 'nom-ville'] [/ types]
The correspondence with yoastseo is: %%cf_wpcf-nom-ville%%
It works well ! Good
But for this shortcode with parrent I can't get it to work.
Example shortcode: [types field = 'cp2-departement' item = '@ departement-ville.parent'] [/ types]
What is the structure to do for yoastseo so that it appears in the title ???
Yoast told me to ask you because it should work the same.
Hello. Thank you for contacting the Toolset support.
AS per the Yost's Doc, for such fields, you will require to create your own custom field placeholder and assign the value of that variable.
=> hidden link
Thank you for your reply. I understand for a hard variable. But how to do the php code to retrieve a value from the parent automatically based on the page?
Using which you can get the parent ID of current child post.
For example;
global $post;
$parent_id = toolset_get_related_post( $post->ID, 'post-relationship-slug');
// getting custom field value that belongs to parent post
$field_value = get_post_meta($parent_id,'wpcf-cp2-departement',true);
Where:
- You should replace "post-relationship-slug" with your original post relationship slug
I hope above solution clarify how you can get parent ID and get the parent custom field value.