'string', 'single' => true, 'show_in_rest' => true, 'sanitize_callback' => 'wp_kses_post', 'auth_callback' => 'skrift_ratgeber_meta_auth', 'description' => 'Kurzantwort auf die Hauptfrage des Artikels', ) ); // Ziel des Call-to-Action, als URL. register_post_meta( 'post', 'cta_ziel', array( 'type' => 'string', 'single' => true, 'show_in_rest' => true, 'sanitize_callback' => 'esc_url_raw', 'auth_callback' => 'skrift_ratgeber_meta_auth', 'description' => 'Zieladresse des Call-to-Action', ) ); // Stand des Artikels als ISO-Datum (YYYY-MM-DD). register_post_meta( 'post', 'stand_datum', array( 'type' => 'string', 'single' => true, 'show_in_rest' => true, 'sanitize_callback' => function ( $wert ) { return preg_match( '/^\d{4}-\d{2}-\d{2}$/', (string) $wert ) ? $wert : ''; }, 'auth_callback' => 'skrift_ratgeber_meta_auth', 'description' => 'Stand des Artikels, Format YYYY-MM-DD', ) ); /** * FAQ als wiederholbare Gruppe. * WordPress braucht fuer verschachtelte Werte ein explizites Schema, * sonst lehnt die REST-API das Schreiben ab. */ register_post_meta( 'post', 'faq', array( 'type' => 'array', 'single' => true, 'default' => array(), 'show_in_rest' => array( 'schema' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'properties' => array( 'frage' => array( 'type' => 'string' ), 'antwort' => array( 'type' => 'string' ), ), 'additionalProperties' => false, ), ), ), 'auth_callback' => 'skrift_ratgeber_meta_auth', 'description' => 'Liste aus Frage-Antwort-Paaren', ) ); } ); /** * Ausgabe der FAQ im Beitrag. * Verwendung im Elementor-Shortcode-Widget: [skrift_faq] * Optional mit Ueberschrift: [skrift_faq titel="Haeufige Fragen"] */ add_shortcode( 'skrift_faq', function ( $atts ) { $atts = shortcode_atts( array( 'titel' => '', 'post_id' => 0, ), $atts, 'skrift_faq' ); $post_id = $atts['post_id'] ? (int) $atts['post_id'] : get_the_ID(); $faq = get_post_meta( $post_id, 'faq', true ); if ( empty( $faq ) || ! is_array( $faq ) ) { return ''; } $html = '