I'm building a car listing site which needs custom schema added to each vehicle.

The schema doesn't comply with the standards sets, this is the example I've been sent:


I would like to find a way to generate the fields and output to JSON. I've used a custom field and added the data above which works well but isn't user friendly.

  • Hi Marco! I'm having trouble understanding your question. Are you asking for advice or is there code we could be looking at to better understand how we can answer your question? – MikeNGarrett Apr 11 at 18:22
  • 1
    Hi Mike, thank you for your response, I'm looking for ideas as I'm not sure where to start. I've created a custom post for a car, now I need to add custom schema data to the listing and output to a feed. I looked at schema plugins but they only output standard schema types. I can use a single custom field to input all the schema data, it works but it's messy for the customer to input this kind of data. I would like to use various fields that the customer can type into, to generate the custom schema. I hope that makes more sense now, many thanks. – Marco Foots Apr 12 at 8:16

I've used a custom field and added the data above which works well but isn't user friendly.

Use Custom Post Types and add Meta Boxes to make it user friendly.

Here's a basic example of adding a custom post type:

function create_post_type() {
  register_post_type( 'car',
      'labels' => array(
        'name' => __( 'Cars' ),
        'singular_name' => __( 'Car' )
      'public' => true,
      'has_archive' => true,
add_action( 'init', 'create_post_type' );

You can also include Custom Taxonomies for fields like category, price_type, make, model, advert_type, etc.

  • Hi Qaisar, Thank you for your response, I've already setup a custom post type. I need to add custom schema data to it. – Marco Foots Apr 12 at 8:19
  • 1
    @MarcoFoots I know this answer focuses on creating the custom post type and taxonomies, but the part you're looking for is also here. Check out the "add Meta Boxes" link in Qaisar's answer. – MikeNGarrett Apr 12 at 13:32
  • @MikeNGarrett I've setup a custom post and added various custom fields using Advanced Custom Fields. The data can be viewed here: khclassics-co-uk.stackstaging.com/wp-json/wp/v2/classic_car However, when I validate the schema, I get an error: Invalid type. Expected Object but got Array. To validate I'm using the schema from here: carandclassic.co.uk/feed/schema.json Do you know how I can output an Object rather than an Array? I've looked in various place but can't find an answer that works. Many thanks. – Marco Foots Apr 23 at 12:08
  • @MarcoFoots Please post this as a separate question. – MikeNGarrett Apr 23 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.