Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.76k stars 887 forks source link

Hooks for the OG:description and Title are no longer getting called. #21672

Closed MGParisi closed 4 days ago

MGParisi commented 6 days ago

Please give us a description of what happened

add_filter( 'wpseo_title', array( $this, 'replace_title_text_pre' ), 10, 1 ); add_filter( 'wpseo_opengraph_title', array( $this, 'replace_title_text_pre' ), 10, 1 ); add_filter( 'wpseo_metadesc', array( $this, 'replace_title_text_pre' ), 10, 1 ); add_filter( 'wpseo_opengraph_desc', array( $this, 'replace_title_text_pre' ), 10, 1 );

None of these hooks work any more, it stopped working a few moths ago. Not sure why.

To Reproduce

Step-by-step reproduction instructions

  1. Not sure

Expected results

  1. The hooks get called.

Actual results

  1. The hooks do not get called.

Screenshots, screen recording, code snippet

If possible, please provide a screenshot, a screen recording or a code snippet which demonstrates the bug.

Technical info

Used versions

MGParisi commented 6 days ago

To be clear, the hooks do get called, but they do not allow changing of the og:title or og:description fields.

MGParisi commented 6 days ago

Also it appears that the og:title and og:description use to come from the Yoast Meta field an Yoast Description, but they no longer do. They now come from the Excerpt and page title.

MGParisi commented 6 days ago

add_filter('wpseo_title', array('custom_og_title'), 10, 2);

public function custom_og_title($title, $presentation = NULL) { return 'CHANGED!' }

Doesn't change, this is on a custom content type and ASTRA theme, but I think its related to yoast, though I can't find the change or where it happened.

josevarghese commented 5 days ago

Hi @MGParisi

Thanks for using the Yoast SEO plugin and for creating the issue.

I tried to replicate the issue and noticed that the wpseo_title, wpseo_opengraph_title, wpseo_metadesc, and wpseo_opengraph_desc filters are working without any problems.

Please try the following function to check this further and let us know the results.

/**
 * Filters the og: description.
 *
 * @param string $description The current page's generated og description.
 *
 * @return string The filtered meta og description.
 * Change the page ID 386 with the page ID at which you are testing
 */
function prefix_filter_og_description_example( $description ) {
  if ( is_page( 386 ) ) {
    $description = 'My custom custom meta description';
  }
  return $description;
}
add_filter( 'wpseo_opengraph_desc', 'prefix_filter_og_description_example' );

If the steps to replicate it are entirely different, please share the code so we can check this further.

We look forward to hearing from you and are happy to help you.

MGParisi commented 4 days ago

It is not working. I used the same code, without the if statement as you did. Its not working in the Page, or the Posts, or any custom content.

MGParisi commented 4 days ago

I've isolated it to the Blog2Social plugin, I will file a ticket there.

josevarghese commented 4 days ago

Thanks for letting us know @MGParisi

I am closing this issue as the filter is working fine without any problems.

We have the following support channels for support:

Thank you for your understanding.