SEO listing is missing JobOffer-schema attributes

Hello,

My SEO Schema JobOffer is not working correctly. It is missing the attibutes below.
Where the title should be the listing title. and Location should be build as followed:

  "jobLocation": {
  "@type": "Place",
    "address": {
    "@type": "PostalAddress",
    "streetAddress": "1600 Amphitheatre Pkwy",
    "addressLocality": "Mountain View",
    "addressRegion": "CA",
    "postalCode": "94043",
    "addressCountry": "US"
    }
  },

These items are missing (Each listing can have a different JobLocation) and hiringOrganization).

Please try using this code snippet to add the missing properties:

add_filter(
	'hivepress/v1/models/listing/schema',
	function( $schema ) {
		$listing = hivepress()->request->get_context( 'listing' );

		if ( ! $listing ) {
			return $schema;
		}

		$schema['title'] = $listing->get_title();

		$schema['jobLocation'] = $listing->get_location();
		$schema['datePosted']  = $listing->get_created_date();

		$image = $listing->get_vendor__image();

		if ( $image ) {
			$image = $image->get_url( 'thumbnail' );
		}

		$schema['hiringOrganization'] = [
			'name' => $listing->get_vendor__name(),
			'logo' => $image,
		];

		return $schema;
	}
);

Works like a charm! Thank you.

Is it possible to upgrade the code a bit? I want the adress line of the jobLocation as following. For this i add attributes to the vendor (all text fields) See screenshot below:

Where i want to map the following structure:

Please can you help me upgrading the code to this markup?

It’s possible to add extra details (e.g. based on the existing listing attributes), but unfortunately there’s no way to break the location text into address parts, since there’s no specific structure. A possible workaround is breaking it by comma but this may not be reliable.

Hello, this is why i made the extra attributes at the Vendor so you don’t need to break down the addres.

Can you please tell me how to get the value of the extra attributes? We prefer to use the vendor attributes as i told in the first reaction.

So: (Ventor attribute) (postadres) should be:

"jobLocation": {
  "@type": "Place",
    "address": {
    "@type": "PostalAddress",
    "streetAddress": "Vendor > {$straat}",
    "addressLocality": "Vendor > {$plaatsnaam}",
    "postalCode": "***{$postadres)***",
    "addressCountry": "NL"
    }
  },

Do you understand my question?

It should be something like this i assume:

$schema['jobLocation'] = [
    '@type' => 'Place',
    'address' => [
        '@type' => 'PostalAddress',
        'streetAddress' => 'Vendor > ' . $listing->get_vendor__address(),
        'addressLocality' => 'Vendor > ' . $listing->get_vendor__city(),
        'postalCode' => 'Vendor > ' . $listing->get_vendor__postcode(),
        'addressCountry' => 'NL'
    ]
];

Hello,

I tried some stuff and got it solved, thank you for your support!

	$schema['jobLocation'] = [
'@type' => 'Place',
'address' => [
    '@type' => 'PostalAddress',
    'streetAddress' => $listing->get_vendor__straat(),
    'addressLocality' => $listing->get_vendor__plaatsnaam(),
    'postalCode' => $listing->get_vendor__postadres(),
    'addressCountry' => 'NL'
]

];

1 Like

Thanks for sharing the solution!

Yes, if you have these details as separate attributes, you can get any attribute via the $listing->get_attributenamehere() code.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.