• Hi,

    I am currently using the 12.5 version of Yoast SEO. I am handling all the schema output myself in my custom theme. It is a very complex setup that would require a lot of work to integrate it with the Yoast Graph, so I have disabled the schema output of the plugin entirely using the wpseo_json_ld_output filter.

    However, I would still very much like to have the schema markup only for the breadcrumbs. I read the API but unfortunately I haven’t found something to help me achieve this. So I currently have the breadcrumbs enabled, but there’s so schema output associated with it.

    Any input would be greatly appreciated.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Sa?a

    (@stodorovic)

    You could use filter wpseo_schema_graph_pieces to “customize” array of “schema objects”. I can’t say more details, but you can see arguments in source code (frontend/schema/class-schema.php). Anyway filter wpseo_json_ld_output is deprecated.

    Thread Starter Ovidiu Nicolae

    (@ovinic)

    Thank you for your reply, Sa?a.
    The wpseo_json_ld_output filter still appears in the api documentation here, so I am a bit surprised that it is deprecated.

    EDIT: you are right, in class-schema.php it was deprecated.

    So the idea would be to use wpseo_schema_graph_pieces instead of wpseo_json_ld_output and basically remove all schema except for breadcrumbs?

    Thanks again for your help.

    Sa?a

    (@stodorovic)

    The filter wpseo_json_ld_output can only prevent entire output and there still isn’t a warning about deprecation (except as the text in the argument). You can create new array with only breadcrumb object and pass it to the filter wpseo_schema_graph_pieces.

    Other solution which I just found. You can use specific filter for each class:

    add_filter( 'wpseo_schema_needs_person', '__return_false' );
    add_filter( 'wpseo_schema_needs_website', '__return_false' );
    add_filter( 'wpseo_schema_needs_mainimage', '__return_false' );
    add_filter( 'wpseo_schema_needs_webpage', '__return_false' );
    add_filter( 'wpseo_schema_needs_article', '__return_false' );
    add_filter( 'wpseo_schema_needs_author', '__return_false' );
    add_filter( 'wpseo_schema_needs_faq', '__return_false' );
    add_filter( 'wpseo_schema_needs_howto', '__return_false' );
    

    It seems as easier and clearer solution.

    UPDATE: You don’t need to explicitly enable breadcrumbs, so I didn’t add filter wpseo_schema_needs_breadcrumb.

    Thread Starter Ovidiu Nicolae

    (@ovinic)

    Sa?a, that is perfect. It’s exactly what I needed. Many thanks for your help!

    This second solution is easier and simpler, but I think one downside would be that in the future, as the Yoast team adds new classes, it will need to be constantly updated.

    I tried to use the wpseo_schema_graph_pieces filter but didn’t manage to make it work. Could you share an example of that as well?

    Thanks again

    Sa?a

    (@stodorovic)

    Yoast team is working on big changes in the code. They will drop support for PHP < 5.6 and WP < 5.2 soon (in one of next releases). Side effect could be moving some classes in different namescapes. So, I’m not sure that first solution is better than second. Anyway you should check the code in the future regardless to current solution.

    I’ll think about sharing the code. You can use get_class or instanceof to check “name”. If you use foreach loop then you should use key to unset a element from the array.

    Thread Starter Ovidiu Nicolae

    (@ovinic)

    Understood, many thanks again for taking the time to help. Much appreciated

    @stodorovic Thanks so much! I was running a pre v11 version of Yoast because of their compulsory schema and because I never figured out how to keep breadcrumbs myself. But with your solution i can finally update!!! which is great because v10 breaks classic editor text mode.

    THANKS!

    As it appears the topic has been resolved we will close it to keep the overview.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Output Yoast schema markup only for Breadcrumbs’ is closed to new replies.