I’m trying to change the schema on my website to work with my custom post types, so events/jobpostings can be categorized as such.

But trying to work with a hook found on Yoast’s website, that hook doesnt even seem to be called.

Heres the code i’m working with.

add_filter( 'wpseo_schema_article', 'change_article_to_social_posting' );
add_filter( 'wpseo_schema_webpage', 'change_article_to_social_posting' );
function change_article_to_social_posting( $data ) {
    $meta = get_post_meta(get_the_id());
    if(is_singular('careers')) : 
        $data['@type'] = "JobPosting";
         $data['datePosted'] = get_the_date('c');
    elseif(is_singular('events')) : 
        $data['@type'] = "Event";
        $data['doorTime'] = $meta['event_time'][0];
        $data['startDate'] =  $meta['event_date'][0];
        $data['organizer'] = get_bloginfo('name');
        $data['location'] =  $meta['event_loc'][0];
    elseif(is_singular('post') :
        $data["@type"] =  "Article";
        $data["articleBody"] = strip_tags(get_the_content());
    else : 
        $data["@type"] = "WebPage";
    //$data['@type'] = 'SocialMediaPosting';
    return $data;

For some reason, this doesn’t seem fo be able to change the ld+json of the page.