Skip to content Skip to navigation
Back to the main support

How to use automatic schema with MyListing WordPress theme

First step

The first thing to do is adding this filter to your functions.php of your child theme (or theme / must use plugin) to show hidden fields in the SEO, Schemas, Custom fields dropdowns:

function sp_get_custom_fields($cf_keys) {
    //example to show all custom fields including hidden ones
    global $wpdb;
    $limit = (int) apply_filters('postmeta_form_limit', 650);
    $cf_keys = $wpdb->get_col("
			SELECT meta_key
			FROM $wpdb->postmeta
			GROUP BY meta_key
			HAVING meta_key NOT LIKE '\_seopress%%'
			ORDER BY meta_key
			LIMIT $limit");

    return $cf_keys;
add_filter('seopress_get_custom_fields', 'sp_get_custom_fields');

Note the “650” value. This is the number of the max number of custom fields you can see in the select (default: 250 for performance reasons).

Increase the value if necessary.

Second step

Add a custom taxonomy called “Schemas” under Listings post type.
From this taxonomy, add some schema names like Local Business, Events, Courses…
Then, edit a listing and apply the correct term.
Eg: if you have an enterprise directory, add the Local Business term to these enterprises.

You can also use the bulk edit feature from the Listings list: select some posts, click Edit from the Bulk actions dropdown and Apply.

Why we need this? To target your content with a specific automatic schema.

Third step

Go to SEO, Schemas, edit your automatic schema.
In the Rules section, select Post type is equal to Listings AND taxonomy is equal to Local Business.

MyListing saves its data in post meta table (ie: custom fields) starting by “_job_name_of_your_custom_field”.

Map your data by selecting custom fields, custom taxonomies etc. You can also use this filter to add your own predefined dynamic variable.

The easiest to map all the schema properties for Google is to create their equivalent with custom fields in MyListing.

Save changes.

Clear your cache if necessary.

Final step

Test one of your URL with Google Structured data testing tool to make sure everything is working as expected.

Disable also the schema generated by MyListing to avoid duplicated schemas.

Et voilà !