AyeCode / geodirectory

GeoDirectory is the leading Directory Plugin for WordPress. Compatible with Gutenberg and the most popular page builders such as Elementor, Oxygen, Beaver Builder and Divi. GeoDirectory is the only solution for WordPress that can scale to millions of listings and high traffic.
https://wpgeodirectory.com/
Other
40 stars 21 forks source link

Integrate Schema for JobPosting Schema type in Geodirectory #1952

Open 1naveengiri opened 2 years ago

1naveengiri commented 2 years ago

https://secure.helpscout.net/conversation/1663366831/25522

add_filter( 'geodir_details_schema', 'geodir_details_schema_custom_callback', 10, 2 );
function geodir_details_schema_custom_callback( $schema, $post ){
    global $gd_post;
    error_log( print_r( $gd_post, true ));
    if( !empty( $schema['@type'] ) && $schema['@type'] == 'JobPosting' ) {
        $schema['title'] = $post->post_title;
        $schema['datePosted'] = $post->post_date;
        $schema["jobLocation"] = array(
            "@type" => "Place",
            "address" => array(
                "@type" => "PostalAddress",
                "streetAddress" => $gd_post->street,
                "addressLocality" => $gd_post->city,
                "addressRegion" => $gd_post->region,
                "postalCode" => $gd_post->zip,
                "addressCountry" => $gd_post->country
            )
        );

        $schema["hiringOrganization"] = array(
            "@type" => "Organization",
            "name" => get_the_title( $gd_post->gd_place ),
            "sameAs" => get_permalink( $gd_post->gd_place ),
            "logo" => get_the_post_thumbnail_url( $gd_post->gd_place, 'full' )
        );

        $schema["baseSalary"] = $gd_post->price;
        $schema["validThrough"] = '';
        $schema["employmentType"] = 'CreativeWork';
    }
    return $schema;
}
alexrollin commented 2 years ago

because this is dependent on some specific fields? then we also should consider adding the fields?