Open benvaassen opened 6 years ago
Please inform the customer of conversation # 281195 when this conversation has been closed.
Please inform the customer of conversation # 281195 when this conversation has been closed.
I believe the same issue persists on other taxonomies as well. I have just tested in on a Brand taxonomy page (built with Perfect WooCommerce Brands) and custom field variables do not get replaced with their values (neither in the Snippet Editor nor the HTML of the page).
Please inform the customer of conversation # 297727 when this conversation has been closed.
Please inform the customer of conversation # 314267 when this conversation has been closed.
Any updates on this? I think this has been a problem for a long time.
The problem is inside inc/class-wpseo-replace-vars.php
on line 679
private function retrieve_cf_custom_field_name( $var ) {
global $post;
$replacement = null;
if ( is_string( $var ) && $var !== '' ) {
$field = substr( $var, 3 );
if ( ( is_singular() || is_admin() ) && ( is_object( $post ) && isset( $post->ID ) ) ) {
$name = get_post_meta( $post->ID, $field, true );
if ( $name !== '' ) {
$replacement = $name;
}
}
}
return $replacement;
}
%%cf_<custom-field>%%
will not work as it is not designed to work with the possible solution would be add additional if statements for is_tax() is_archive() etc and add relevant function to retrieve taxonomy and archive custom fields using get_term_meta function
Hi there,
This issue has been ongoing since the start of the year. Is there any progress on it? Looking to implement this as soon as possible in one of my projects.
Thanks!
Any progress on the issue? I cannot use %%cf_
Same issue. On a custom category page, trying to put custom field into Yoast meta description.
Added custom field "medium" via ACF:
Content shown in snippet preview is a:1:{i:0,s:20:"Fine Art Photography";} but should just read Fine Art Photography.
Description in source code reads "Array".
WP: 4.9.6 Yoast: 7.7.2 ACF Content Analysis for Yoast SEO: 2.0.1 ACF: 4.4.12
I have same prob with acf field on custom taxonomy archive. Any info about this? Is been a long time ago since that issue not resolved.
Same issue. When putting only %%cf_acf_category%% in the SEO title in the meta box snippet, the output defaults to Title Separator Site title, the same output if you leave the SEO title blank. Therefore, %%cf_acf_category%% is not outputting anything.
Yoast SEO Premium 9.0.3 WordPress 4.9.8 ACF 5.7.7
The problem is inside
inc/class-wpseo-replace-vars.php
on line 679private function retrieve_cf_custom_field_name( $var ) { global $post; $replacement = null; if ( is_string( $var ) && $var !== '' ) { $field = substr( $var, 3 ); if ( ( is_singular() || is_admin() ) && ( is_object( $post ) && isset( $post->ID ) ) ) { $name = get_post_meta( $post->ID, $field, true ); if ( $name !== '' ) { $replacement = $name; } } } return $replacement; }
%%cf_<custom-field>%%
will not work as it is not designed to work with the possible solution would be add additional if statements for is_tax() is_archive() etc and add relevant function to retrieve taxonomy and archive custom fields using get_term_meta function
Thank you for the tip.
I have a custom section with acf fields added, which in no way wanted to be displayed in yoast.
After some research, I was able to map the value of the acf fields to yoast fields as follows:
Edited the method retrieve_ct_custom_tax_name
private function retrieve_ct_custom_tax_name( $var, $single = false ) {
$replacement = null;
$tax = substr( $var, 3 ); // name field
if ( ( is_string( $var ) && $var !== '' ) && ! empty( $this->args->ID ) ) {
$name = $this->get_terms( $this->args->ID, $tax, $single );
if ( $name !== '' ) {
$replacement = $name;
}
} else {
$term = get_term_by( 'slug', get_query_var( 'explore_region' ), 'region' );
$field = get_field( $tax, $term ); // field data
$name = $field['region_seo_type'];
if ( $name !== '' ) {
$replacement = $name;
}
}
return $replacement;
}
P.S. Everything works even without the additional acf-content-analysis-for-yoast-seo plugin
Issue still relevant in Yoast SEO 20.8. I tried to add a snippet variable for an ACF custom field, i.e. second_description
, to the meta description of a category page; however, after saving the page, the variable I added %%cf_second_description%%
got replaced with %%_second_description%%
which is then output in the frontend. See screencast below.
https://github.com/Yoast/wordpress-seo/assets/9658774/52ba2c9c-04ae-4f0c-8e5b-67c6f4271446
Please inform the customer of conversation # 1023742 when this conversation has been closed.
Probably related https://github.com/Yoast/wordpress-seo/issues/20487
Issue still relevant in Yoast SEO 20.8. I tried to add a snippet variable for an ACF custom field, i.e.
second_description
, to the meta description of a category page; however, after saving the page, the variable I added%%cf_second_description%%
got replaced with%%_second_description%%
which is then output in the frontend. See screencast below.Screen.Recording.2023-06-05.at.12.11.19.88.PM.mp4
Still seeing this issue on the latest release. Is there any path to resolve this?
Please give us a description of what happened.
The advanced variable %%cf_%% doesn't show anything.
Please describe what you expected to happen and why.
I expect to see the content of my custom field on that category in the title in my Snippet Preview.
How can we reproduce this behavior?
Technical info