Adding microdata using Structured Data Markup Helper HTML

I am trying to add schema microdata to a wordpress website. I have tried to insert some microdata directly in the wp editor (text mode) but every time i save the page it does not save the code.

I tried a few plugins but when I check with the structured testing tool it doesn't seem like they are working.

I generated the microdata using this tool, but I am not able to edit the html. Can I do it via cpanel? I cannot find how i can edit the html under the cpanel.

How can I add the generated data to the home page?

Topic tinymce visual-editor html Wordpress

Category Web


By default TinyMCE, the (visual) editor of WordPress, strips schema microdata from input. There are plugins (example) that will prevent this behaviour. Or you can do it yourself by adding this snippet to your functions.php (docs):

function wpse238918_allow_schema ($in) {
    if(!empty($in['extended_valid_elements']))
        $in['extended_valid_elements'] .= ',';
    $in['extended_valid_elements'] .= '@[id|class|style|title|itemscope|itemtype|itemprop|datetime|rel],div,dl,ul,dt,dd,li,span,a|rev|charset|href|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur]';
    return $in;
    }
add_filter('tiny_mce_before_init', 'wpse238918_allow_schema' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.