PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

“SEO URL request” – No support for WPBakery or JSON-LD schema markup

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
12

Hi Support Team,

We are currently using the “SEO URL request” feature to insert optimized SEO content on our landing pages. However, we’ve encountered two major limitations:

  1. The section does not support WPBakery (Visual Composer) – layout elements and shortcodes cannot be used.

  2. <script type="application/ld+json"> is not processed, meaning we cannot add structured data (e.g. FAQPage schema) directly for Google’s rich results.

SEOPress is installed and active on our website, but it does not provide an option to insert structured data for this specific “SEO URL request” section. Therefore, we need to manually embed JSON-LD schema markup directly within this field, which currently seems unsupported.

Our questions:

  • Is there a way to allow <script type="application/ld+json"> inside the SEO URL request field, so the structured data is rendered properly on the frontend?

  • Alternatively, is there another recommended method to add custom JSON-LD schema markup per page, outside of this restricted field?

We would greatly appreciate your help or any possible solution to make schema integration SEO-compliant.

Best regards,

Hello

Do you mean these fields? - https://share.pluginus.net/image/i20251006205949.png

You can customize these fields using hooks - woof_seo_meta_description  woof_seo_meta_title  woof_seo_meta_title   woof_seo_h1

 

Hello Pablo,

thanks for your reply.

The actual issue is that the “SEO URL request” field correctly outputs normal HTML elements like <h1>, <h2>, <p>, etc., but it does not work with <script type="application/ld+json"> ... </script>.

When we insert JSON-LD schema markup, it is not rendered as a script on the frontend. Instead, only a broken text snippet appears (for example, it ends in the middle of a curly bracket }), which makes the markup invalid.

In other words, structured data cannot currently be added via this field because <script> tags seem to be filtered or altered.

Could you please confirm whether this field fundamentally does not support <script> tags, or if there is an option/extension to make JSON-LD render correctly?

Best regards

Hello

Of course, this is done for the security of the site.

In your case, you need code customization.

I've written to you under"Your topic private data." Thanks.

Hello

ok! I answered you under private data.

Hello, thanks anyway, can you please tell me where I need to have it adjusted?

Hello

Unfortunately, I didn't understand your question.

If you need a file with SEO functionality -"\plugins\woocommerce-products-filter\ext\url_request\classes\seo.php"

Hello, thanks for the feedback. I've tried a few things, but somehow it's not being accepted and isn't working.

I really need help.

Hello

You can hire a developer to customize the code, and we will share with them any technical information about our plugin.

Hi Pablo,

we’ve implemented several fixes to prevent WordPress (and related plugins) from filtering or breaking our JSON-LD schema output.
Specifically, we added a custom MU plugin (json-ld-fix.php) that disables sanitization and formatting functions such as wp_kses_post, wpautop, and plugin-specific filters.

Despite these adjustments, the issue persists:

  • The <script type="application/ld+json"> blocks are still being altered on output.

  • Sometimes commas or braces are misplaced (for example: , } or empty script tags).

  • The JSON-LD schema fails to validate correctly in Google’s Rich Results test.

We suspect that another layer of filtering or output buffering is still affecting the JSON-LD data — possibly a core sanitization in the SEO or caching process.

Could you please review the current implementation and help identify what additional hook or sanitization step needs to be bypassed so that the schema is rendered exactly as entered (raw JSON-LD output, unescaped and unfiltered)?

We can provide access to the MU plugin and affected templates if needed.
Your help in pinpointing the remaining cause of the malformed JSON output would be greatly appreciated.

Best regards

<?php
/**
* Plugin Name: JSON-LD Fix (Unfiltered Output)
* Description: Prevents WordPress or plugins from altering or sanitizing JSON-LD structured data.
* Version: 2.0
* Author: Developer
*/

if (!defined('ABSPATH')) exit;

/**
* 1. Skip sanitization when saving options.
* This prevents the removal of <script> tags and curly braces from JSON-LD content.
*/
add_filter('sanitize_option', function($value) {
if (is_string($value) && stripos($value, 'application/ld+json') !== false) {
return wp_unslash($value);
}
return $value;
}, 1, 1);

/**
* 2. Output fix – disables cleanup of JSON-LD output.
* Removes unwanted commas, empty objects, and <p> wrappers from JSON-LD.
*/
add_filter('rich_snippets_json_output', function($output) {
if (is_string($output) && stripos($output, 'application/ld+json') !== false) {
$output = preg_replace('/,\s*,+/', ',', $output);
$output = preg_replace('/\},\s*,\s*\{/',"},\n{", $output);
$output = preg_replace('/,\s*\}/', '}', $output);
$output = str_replace(['<p>', '</p>', '&nbsp;'], '', $output);
return wp_unslash($output);
}
return $output;
}, 9999);

/**
* 3. Also remove wp_kses_post() from other output hooks.
*/
add_filter('rich_snippets_html_output', function($html) {
if (is_string($html) && stripos($html, 'application/ld+json') !== false) {
$html = preg_replace('/,\s*,+/', ',', $html);
$html = preg_replace('/\},\s*,\s*\{/',"},\n{", $html);
$html = preg_replace('/,\s*\}/', '}', $html);
$html = str_replace(['<p>', '</p>', '&nbsp;'], '', $html);
return wp_unslash($html);
}
return $html;
}, 9999);

/**
* 4. Extend wp_kses to allow <script type="application/ld+json"> tags
* in all relevant contexts (post, meta, options, etc.).
*/
add_filter('wp_kses_allowed_html', function($tags, $context) {
$contexts = ['post', 'data', 'option', 'meta', 'user_description'];
if (in_array($context, $contexts, true)) {
$tags['script'] = ['type' => true, 'id' => true];
}
return $tags;
}, 10, 2);

/**
* 5. Remove auto-generated <p> or <br> tags that WordPress may insert around scripts.
* This prevents broken JSON-LD blocks caused by wpautop().
*/
add_filter('the_content', function($content) {
if (stripos($content, 'application/ld+json') !== false) {
$content = preg_replace('/<p>(\s*<script type="application\/ld\+json">.*?<\/script>)<\/p>/is', '$1', $content);
}
return $content;
}, 0);

/**
* 6. Final output buffer cleanup – remove empty or malformed script blocks
* that could result in trailing commas or invalid JSON syntax.
*/
add_action('template_redirect', function() {
ob_start(function($buffer) {
$buffer = preg_replace('/<script type="application\/ld\+json">\s*,\s*<\/script>/', '', $buffer);
$buffer = preg_replace('/<script type="application\/ld\+json">\s*<\/script>/', '', $buffer);
return $buffer;
});
});

Hello

Lets begin from the begining :)

  • Is there a way to allow <script type="application/ld+json"> inside the SEO URL request field, so the structured data is rendered properly on the frontend?

  • Alternatively, is there another recommended method to add custom JSON-LD schema markup per page, outside of this restricted field?

So how I understand the problem - it is implementing json schema into rendered html page. What I suggest it is manipulating with hook woof_seo_h1 https://share.pluginus.net/image/i20251020134054.png

add_filter('woof_seo_h1', function($h1_text) {
global $woof_json_ld;//create it somewhere
//Google processes JSON-LD anywhere in the body. But the problem is that if you
//add the script via the woof_seo_h1 filter, it will be output directly in the h1 location, which can look awkward in the code.
    $json_ld = wp_json_encode([
        '@context' => 'https://schema.org',
        '@type' => 'TODO',
        'mainEntity' => [
            //your logic
        ]
    ]);
    $h1_text .= '<script type="application/ld+json">' . $json_ld . '</script>';
    return $h1_text;
});
add_action('wp_footer', function() {
    global $woof_json_ld;
    if (!empty($woof_json_ld)) {
        echo '<script type="application/ld+json">';
        echo wp_json_encode($woof_json_ld);
        echo '</script>';
    }
});

 

So, in the moment of generating you can add ld+json data into the page footer, and you not need fix HUSKY code, let it works as is. I hopr I undertood you right, and suggested relevant way ...

 

Hello, thanks for the feedback. Unfortunately, we can't do it :-( It would be important that each generated page, etc., has its own schema, like in SEO, that functions flawlessly.

When would you have resources for this again?

Thanks for the support

Hello

Maybe I not undertand you right, but looks like I not understand what you want, as you need it for each page I see you can do it with suggested script, you can manipulate with ld json for each request, what is nessesary is to create right logic how to generate inside data for that script

Hello Alex and Pablo, under"sEO URL request" you can enter the meta title, H1 title, meta description, and SEO text. We're missing the important option for"schema markup" here, so we can store our data individually for each category, specifically for AI, AI, and traditional search.

Unfortunately, this is currently not possible using:

<script type="application/ld+json">
{
}
}
}
</script>

Hello Bulli

Make please video where described with visible links: what data you see on pages, how HUSKY influent on it, how you inserted it there, and how you can manipulate with it

Hi Alex,
thanks for your feedback.

Currently, when I insert the following code under the SEO text:

<script type="application/ld+json">
{
}
}
}
</script>

the code is displayed incorrectly as:

{
}
}
}

As a result, it isn’t recognized properly and produces error messages in the Google Schema Validator.

At the moment, I’m not using my code because unfortunately it’s not working as intended.

IMG LINK: https://ibb.co/5ghRPhV2

Best regards

Hello Bulli

Now I understand. Its not possible in the way you doing because of tag filtering by the code according to security actions. BUT I will look into the code and will think will it be posssible to add special hooks into HUSKY plugin to get around this problem and solve everything with code in file functions.php. I will back this ticket within 5 working days ...

Hello Bulli

So I looked this task, and look here is suggetion:

  1. Into file functions.php add next code:
    add_action('init', function () {
    $url_request=WOOF_EXT::$includes['applications']['url_request'];
    remove_filter('woocommerce_after_shop_loop', array($url_request->seo, 'add_seo_text'), 99999);

    add_filter('woocommerce_after_shop_loop', function () use($url_request) {
    $rule = $url_request->seo->check_search_rules();
    if (!isset($rule['text']) || !$url_request->seo->do_index()) {
    return;
    }

    $txt = apply_filters('woof_seo_text', $url_request->seo->replace_vars($rule['text'], $url_request->seo->get_current_replace_vars()));

    if (!empty($txt)) {

    switch ($txt) {
    case 'sh1':

    $txt="<script type='application/ld+json'>{a:'hello'}</script>";

    break;

    default:
    break;
    }

    echo '<div class="woof_seo_text">' . $txt ."</div>\r\n";
    }
    }, 99999);
    }, 1);

  2. in HUSKY admin just set key for schemas https://share.pluginus.net/image/i20251103142130.png
  3. in code write your schema as you want, I just checked and it works fine https://share.pluginus.net/image/i20251103142227.png

Try it ...

 

 

Hi Alex, thanks for the code.
This is exactly where the problem is. I had to insert the entire code for each category into this field:
https://share.pluginus.net/image/i20251103142130.png

 

Like this:

<script type="application/ld+json">
{
"@context":"https://schema.org",
"@graph": [
{
...
}
]
}
</script>

 

Unfortunately, it doesn’t work.
Could you please take another look and check if everything is correct?
I inserted the code directly into that field.

Thanks so much for your effort and time!

12