FAQ and HowTo Schema Markup in WordPress with JSON-LD

FAQ and HowTo Schema markup helps search engines display rich results — accordion FAQs and step-by-step instructions directly in the SERPs. WordPress does not add this automatically, but you can generate it cleanly from ACF fields or post meta.

Problem: A WordPress site publishes FAQ and how-to content but Google Search Console shows no rich result eligibility — the content is not marked up with structured data that search engines can parse.

Solution: Add JSON-LD FAQPage and HowTo schema to relevant posts by hooking into wp_head and outputting a <script type="application/ld+json"> block. Build the schema array in PHP from ACF fields or post meta, encode it with json_encode(), and validate the output in Google's Rich Results Test.

The examples below output valid FAQPage and HowTo JSON-LD markup via wp_head, pulling questions from a repeater field and steps from a custom meta structure.

 'Question',
            'name'           => wp_strip_all_tags( $item['question'] ),
            'acceptedAnswer' => [
                '@type' => 'Answer',
                'text'  => wp_strip_all_tags( $item['answer'] ),
            ],
        ];
    }

    $schema = [
        '@context'   => 'https://schema.org',
        '@type'      => 'FAQPage',
        'mainEntity' => $entities,
    ];

    echo '' . "
";
} );

HowTo schema for tutorial posts with steps stored in post meta:

 $step ) {
        $step_entities[] = [
            '@type'    => 'HowToStep',
            'position' => $i + 1,
            'name'     => wp_strip_all_tags( $step['title'] ),
            'text'     => wp_strip_all_tags( $step['description'] ),
            'url'      => get_permalink() . '#step-' . ( $i + 1 ),
        ];
    }

    $schema = [
        '@context'        => 'https://schema.org',
        '@type'           => 'HowTo',
        'name'            => get_the_title(),
        'description'     => get_the_excerpt(),
        'totalTime'       => get_post_meta( get_the_ID(), '_howto_duration', true ) ?: 'PT10M',
        'step'            => $step_entities,
    ];

    echo '' . "
";
} );

// Store steps via a metabox save:
add_action( 'save_post', function( int $post_id ) {
    if ( ! isset( $_POST['howto_steps_nonce'] ) ) return;
    if ( ! wp_verify_nonce( $_POST['howto_steps_nonce'], 'save_howto_steps' ) ) return;
    $raw = wp_unslash( $_POST['howto_steps'] ?? [] );
    $clean = array_map( function( $s ) {
        return [
            'title'       => sanitize_text_field( $s['title'] ?? '' ),
            'description' => sanitize_textarea_field( $s['description'] ?? '' ),
        ];
    }, (array) $raw );
    update_post_meta( $post_id, '_howto_steps', $clean );
} );

NOTE: Validate your output with Google's Rich Results Test at search.google.com/test/rich-results. Note that Google only shows FAQ rich results for authoritative government and health sites as of 2023 — HowTo and other schema types still appear for all sites.

Leave Comment

Your email address will not be published. Required fields are marked *