so i got this code

add_filter( 'abcdefg/json_ld', function( $data, $jsonld ) {
    if ( is_single() ) {
        $data['richSnippet']['articleBody'] = $jsonld->post->post_content;
    return $data;   
}, 11, 2);

I'm simply trying to take the post_content and basically deliver only the text, currently its adding WPbakery tags (E.G [vc_row],[vc_column_txt] and so on, and also the usual h1/2/3 and so on)

i can somewhat read PHP code, but no where near the level of writing code. i was trying to take the $data after the return and "proccess" it through wp_strip_tags and then i figured i should probably run $data before it returns.. that didnt work.

so here i am.. any tips? thank you!

also just to make sure, it is running on functions.php.

closed as off-topic by Tom J Nowell Aug 1 at 3:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • What is the jsonld and where does this filter come from? Your code example doesn't include any tag stripping functions so it's not clear how you're trying to use the function – Tom J Nowell Jul 31 at 20:58
  • It seems this is actual a RankMath SEO plugin question, you should contact RankMath SEO plugin support – Tom J Nowell Aug 1 at 3:09

Those aren't HTML tags, those are shortcodes. wp_strip_all_tags will strip out HTML tags such as <p> or <i>. For shortcodes you should strip out the shortcodes

I did a quick google which turned up strip_shortcodes on the official dev docs:


  • seems like wp_strip_tags isnt working anyway, since even the <h1>/<h2> etc... isnt being stripped either. im pretty sure its related to my lack of PHP knowledge rather then what should be stripped out. – Shay Ohayon Jul 31 at 0:51
  • @ShayOhayon you never showed in your question how you were applying the function, so it's possible it's just being applied incorrectly. It's also possible that this plugin doesn't work the way you think it does. Technically the question should be closed as offtopic for being about a 3rd party plugin API, but since I can phrase it to be generic WP, and the code snippet has been modified to make it impossible to identify the plugin I answered – Tom J Nowell Jul 31 at 20:56
  • True, some info is missing, and the code has been modified, it is a RankMath code, i will try and fill in the gaps, so to be clear, the code IS working and functions correctly, when the blog page is being scanned for schema markup via google testing tool the "articleBody" is being added to the schema as intended with the code, howeven it includes a pure "post_content" which means it shows the blog post itself along with the H1/H2/H3 AND <a> and all other HTML related tags along with the text, what i need is ONLY the text, to remove the HTML tags and as you mentioned, the shortcodes – Shay Ohayon Jul 31 at 23:59
  • @ShayOhayon please edit your original question so that it's self contained and complete. What you're describing does not match your original question. Keep in mind this isn't a discussion forum thread – Tom J Nowell Aug 1 at 3:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.