• Resolved Frederic Pilon

    (@frederic-pilon)


    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";
        endif;
        //$data['@type'] = 'SocialMediaPosting';
    }

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

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello Frederic,

    Thanks for reaching out regarding your site schema.

    As much as we hate to say it, your question goes beyond our technical expertise. This means we can’t give you a solid answer to your question or review your code snippet.

    And though we can’t help with specifically, someone from the community might help you when visiting this thread. So, we’ll leave the thread open for a week.

    Thread Starter Frederic Pilon

    (@frederic-pilon)

    …but the github repo support sent me here.

    So, where should I ask things about code?

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    Our GitHub repository is for reporting bugs and issues with the Yoast SEO plugins. For support questions for users of the Yoast SEO plugin, these forums are the right avenue to request support.

    However, we’d like to clarify that we are able to assist with the basic usage and features of the Yoast SEO plugin. Providing custom code specific to your situation is outside our scope of support. Apologies if we couldn’t be of more help here.

    We’d like to refer you to our Schema API, should you want to make any modifications to the default output – https://developer.yoast.com/features/schema/api/

    Thread Starter Frederic Pilon

    (@frederic-pilon)

    That is pretty much the problem @mikes41720. I follow exactly the code that is on that page and it just… doesnt work. (The Change a graph pieces’ data piece)

    Git doesnt want to help. Here neither, and I’m not gonna jump into the fun of analysing the whole plugin code to figure out how to make it work.

    Its annoying as hell.

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    We have a few examples here in the Schema API documentation on how to use those filters to modify the default schema output. If the filter isn’t working as expected, we’d have to check further on how it was used, but we are unable to do so over these public forums. You may also want to contact your web developer to help with the implementation.

    We’ll be keeping this forum thread open for a few days in case there are other users here who may have suggestions or advice. Sorry we couldn’t be of more help here.

    • This reply was modified 3 years, 3 months ago by Michael Ti?a.
    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    This thread has been marked as resolved due to a lack of activity.

    You’re always welcome to re-open this topic. Please read this post before opening a new request.

    Thanks for understanding!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Way to change the Schema depending on post type?’ is closed to new replies.