{"id":5672,"date":"2026-04-18T13:25:38","date_gmt":"2026-04-18T06:25:38","guid":{"rendered":"https:\/\/bisadonasi.com\/wpcode\/auto-faq-scheme\/"},"modified":"2026-04-18T13:25:38","modified_gmt":"2026-04-18T06:25:38","slug":"auto-faq-scheme","status":"publish","type":"post","link":"https:\/\/bisadonasi.com\/?p=5672","title":{"rendered":"Auto FAQ Scheme"},"content":{"rendered":"<p>add_filter( \\&#8217;rank_math\/json_ld\\&#8217;, function( $data, $jsonld ) {<\/p>\n<p>    if ( ! is_single() ) {<br \/>\n        return $data;<br \/>\n    }<\/p>\n<p>    global $post;<br \/>\n    $content = $post->post_content;<\/p>\n<p>    \/\/ Deteksi section FAQ<br \/>\n    if ( stripos( $content, \\&#8217;<\/p>\n<h2>FAQ\\&#8217; ) === false ) {<br \/>\n        return $data;<br \/>\n    }<\/p>\n<p>    preg_match_all(<br \/>\n        \\&#8217;\/Q:\\\\s*(.*?)\\\\s*A:\\\\s*(.*?)(?=Q:|$)\/s\\&#8217;,<br \/>\n        wp_strip_all_tags( $content ),<br \/>\n        $matches<br \/>\n    );<\/p>\n<p>    if ( empty( $matches[1] ) ) {<br \/>\n        return $data;<br \/>\n    }<\/p>\n<p>    $faq = [<br \/>\n        \\&#8217;@type\\&#8217; => \\&#8217;FAQPage\\&#8217;,<br \/>\n        \\&#8217;mainEntity\\&#8217; => []<br \/>\n    ];<\/p>\n<p>    foreach ( $matches[1] as $index => $question ) {<br \/>\n        $faq[\\&#8217;mainEntity\\&#8217;][] = [<br \/>\n            \\&#8217;@type\\&#8217; => \\&#8217;Question\\&#8217;,<br \/>\n            \\&#8217;name\\&#8217; => trim( $question ),<br \/>\n            \\&#8217;acceptedAnswer\\&#8217; => [<br \/>\n                \\&#8217;@type\\&#8217; => \\&#8217;Answer\\&#8217;,<br \/>\n                \\&#8217;text\\&#8217; => trim( $matches[2][ $index ] )<br \/>\n            ]<br \/>\n        ];<br \/>\n    }<\/p>\n<p>    $data[\\&#8217;faq_auto\\&#8217;] = $faq;<br \/>\n    return $data;<\/p>\n<p>}, 99, 2 );<\/p>\n","protected":false},"excerpt":{"rendered":"<p>add_filter( \\&#8217;rank_math\/json_ld\\&#8217;, function( $data, $jsonld ) { if ( ! is_single() ) { return $data; } global $post; $content =\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-5672","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/bisadonasi.com\/index.php?rest_route=\/wp\/v2\/posts\/5672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bisadonasi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bisadonasi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bisadonasi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bisadonasi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5672"}],"version-history":[{"count":0,"href":"https:\/\/bisadonasi.com\/index.php?rest_route=\/wp\/v2\/posts\/5672\/revisions"}],"wp:attachment":[{"href":"https:\/\/bisadonasi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bisadonasi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bisadonasi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}