Title: Description filter does not apply
Last modified: September 6, 2022

---

# Description filter does not apply

 *  Resolved [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * (@thesongoku)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/)
 * Hello guys,
 * before my vacation 3 weeks ago, we had (and still have) the following script 
   in place to get an excerpt from our review cpt description field for the meta
   description.
 * `add_filter( ‘the_seo_framework_generated_description’, function($description,
   $args){
    if ($args === null && get_post_type( get_the_ID() ) == ‘product_reviews’){
   $product = get_field(‘name’, get_the_ID()); $beschreibung = get_field(‘beschreibung’,
   get_the_ID());
 *  if (is_tax()){
    $catTitleRaw = get_the_archive_title(); $newCatTitle = get_string_between(
   $catTitleRaw, ‘<span>’, ‘</span>’); $description = ‘Ließ dir ‘.$newCatTitle.’
   echter Nutzer durch, um die richtige Tool Entscheidung für dein Unternehmen zu
   treffen!’; } else { if(strlen($beschreibung) == 0){ $description = “Du interessierst
   dich für ” . $product . “? Auf OMKB Reviews 2022 erfährst du, was andere Nutzer
   von ” . $product . ” halten.”; } else { $description_ohne_html = substr(strip_tags(
   $beschreibung), 0, 145); $letztesLeerzeichen = strrpos($description_ohne_html,”“);
   $description = substr($description_ohne_html, 0, $letztesLeerzeichen); } }
 *  return $description;
    } }, 10, 2);
 * BUT in the middle of last week I noticed the descriptions are no longer build
   even though we did not change anything.
 * After desperately trying to fix the problem myself, I came to the forum in hope
   one of you can tell me what is going on.
 * $description is filled with the correct excerpt in it, but the content of the
   variable never reaches the meta description which always results empty.
 * We have the same issue in other custom post types as well, but only with the 
   meta descriptions, not the title tags which are build with a filter as well.
 * I am looking forward to your replys!
 * Regards
    Thomas

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-15984041)
 * Hi Thomas,
 * It looks like that filter never should’ve worked correctly in the first place.
   I could list all issues, but here’s an amended copy that should always work: 
   [https://gist.github.com/sybrew/1e61b12893c0089353c53f3bcc126a6b](https://gist.github.com/sybrew/1e61b12893c0089353c53f3bcc126a6b).
 * It is untested, though. Still, enjoy 🙂
 * Please be aware that this snippet is not fully compliant with Google’s guidelines.
   However, my statement here ignores the fact that Google removed their recommendation
   against boilerplates: [https://developers.google.com/search/docs/advanced/appearance/snippet#programmatically-generate-descriptions](https://developers.google.com/search/docs/advanced/appearance/snippet#programmatically-generate-descriptions).
   I’m not sure you can (or must, or should) work around that, though.
 *  Thread Starter [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * (@thesongoku)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-15986378)
 * Hi Sybre,
 * thank you for sharing the code with me.
 * I just tried your code out. The return statement prints the excerpt to the screen
   but not to the meta description though. Do you have an idea on how I can get 
   the generated string in the meta description? And I am still confused why the
   code does not work anymore 😀 I mean, pretty much nothing changed in the last
   weeks.
 * What I am curious to know as well: Why are the description hooks named differently
   compared to the title hooks? Some act pretty similar, but one is called “the_seo_framework_title_from_generation”
   while the description equivalent is called “the_seo_framework_generated_description”.
 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-15989344)
 * Hi Thomas!
 * Have you cleared all the site caches after installing the filter?
 * Please allow me to explain my previous comment “It looks like that filter never
   should’ve worked correctly in the first place.”
 * The old code probably churned out a non-representative cached response sporadically,
   which you might’ve caught during your tests. Much for the same reason that my
   snippet seems to fail now: you’re getting an outdated cached response not reflecting
   the prescribed output.
 * With TSF, I connected the front- to the back end. And to make TSF’s code work
   in tandem, I added the complexity of lines 9 through 27 in the GitHub gist. It
   is why `$args` can be `null` or have any of the `pta/taxonomy/id` sub-values,
   none of which the old snippet considered. Those sub-values are required to display
   the description on the back-end edit screens, which is why you can see the suggested
   description correctly on the back-end screen now.
 * The old snippet always returned `null` on the back end. On the front end, it 
   would return `null` for any request that wasn’t for the `product_reviews` post
   type. This `null` response would clear any generated descriptions. The new snippet
   doesn’t do that, so you can indeed see TSF’s generated descriptions again.
 * The old snippet also didn’t go through TSF’s description “getter” phase 2~9: 
   [https://tsf.fyi/kb/a/65#sequences-getter](https://tsf.fyi/kb/a/65#sequences-getter),
   which might result in a shorter description than what you had before.
 * My point is this: Clear the cache 🙂 If that doesn’t resolve the issue, please
   let me know, and I’ll see if I can replicate your use case.
 * As for your other question: The filters between the title and description have
   a different makeup of names because I implemented them at various stages of plugin
   development. At some point, I opted for one naming scheme over the other. I planned
   to phase out one over the other, but I don’t think it’s important enough to bother
   hundreds of developers with a deprecation notice.
 * I hope this helps! Cheers 🙂
 *  Thread Starter [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * (@thesongoku)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-15991203)
 * Hi Sybre,
 * thank you for your extensive response!
 * As we have a pretty big and complex system, we completely clear our cache almost
   daily (sometimes even several times).
 * Unfortunately the refreshed code does not transport the generated description
   to the meta-description neither, which kinda confuses me, because the “old” meta-
   title code snippets still work. Its just about the meta-description codes which
   do not work.
 * I am looking forward to your reply!
 * Regards
    Thomas
 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16002918)
 * Hi Thomas,
 * Sorry for my belated reply.
 * Please share a few URLs of the pages affected with my proposed snippet active.
   You may do so confidentially at [https://tsf.fyi/contact](https://tsf.fyi/contact).
 *  Thread Starter [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * (@thesongoku)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16013225)
 * Hi Sybre,
 * sorry, I totally missed to reply to you as well. 😀
 * Just filled out the form!
 * Looking forward to your reply!
 * Regards
    Thomas
 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16039313)
 * Hi Thomas,
 * I’m sorry to have kept you waiting. I received your email well.
 * The script I provided works as intended on my site. Note that the script assumes
   you have Advanced Custom Fields enabled. But even if that plugin is disabled,
   it should return a generated description from the content, which it currently
   doesn’t.
 * So, I believe you have accidentally accumulated multiple filters in your codebase
   that overwrite how TSF should behave. You should not have both your and my filters
   active simultaneously — I recommend only using the one I provided.
 * If you are sure you only implemented one filter, please scan for `the_seo_framework_`
   in your custom code active on your website and see if there are overrides; specifically,`
   the_seo_framework_generated_description` might be listed twice, while only the
   one I provided should be active.
 *  Thread Starter [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * (@thesongoku)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16046874)
 * Hi Sybre,
 * thank you for your reply!
 * ACF is enabled on our website.
 * Yeah, I did exactly that. I took the code we had before and completely replaced
   it with the code you provided me.
 * The old codebase is still active for other custom post types though, but with
   an if statement in front (just like in my very first thread) which asks regarding
   the post type. This code does not apply to anything regarding our cpt product_reviews(
   example from the very first post) anymore though.
 *  Thread Starter [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * (@thesongoku)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16068694)
 * Hi Sybre,
 * do you have an update for me?
 * Regards
    Thomas
 *  Plugin Author [Sybre Waaijer](https://wordpress.org/support/users/cybr/)
 * (@cybr)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16082980)
 * Hi Thomas,
 * Sorry for leaving you waiting for so long.
 * Unfortunately, I cannot tell what’s wrong. If you installed my code as-is directly
   in functions.php or a plugin unconditionally, it should work. But perhaps you
   have a plugin or theme conflict, or perhaps there’s a caching issue, or maybe
   a mix of both.
 * Please get in touch with a developer who has unrestricted access to your site
   to find out the cause.
 *  Thread Starter [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * (@thesongoku)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16121281)
 * Hi Sybre,
 * I solved the issue with a custom javascript.
 * Regards
    Thomas

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Description filter does not apply’ is closed to new replies.

 * ![](https://ps.w.org/autodescription/assets/icon.svg?rev=3000376)
 * [The SEO Framework – Fast, Automated, Effortless.](https://wordpress.org/plugins/autodescription/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autodescription/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autodescription/)
 * [Active Topics](https://wordpress.org/support/plugin/autodescription/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autodescription/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autodescription/reviews/)

## Tags

 * [description](https://wordpress.org/support/topic-tag/description/)
 * [filter](https://wordpress.org/support/topic-tag/filter/)

 * 11 replies
 * 2 participants
 * Last reply from: [thesongoku](https://wordpress.org/support/users/thesongoku/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/description-filter-does-not-apply/#post-16121281)
 * Status: resolved