Home › Forums › General Issues › Change canonical tag with custom field › Reply To: Change canonical tag with custom field
Thanks! There seems to be an ACF-related function on that hook page that looks like it might work so I will test that out.
function wpdocs_edit_canonical_urls( $original_url, $post ) {
$override_url = get_post_meta( $post->ID, 'canonical_url', true );
if ( empty( $override_url ) ) {
return $original_url;
}
return $override_url;
}
add_filter( 'get_canonical_url', 'wpdocs_edit_canonical_urls', 10, 2 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.