wp-faq-schema. It will take title and accordion attributes.', 'wp-faq-schema' ), [ 'code' => [] ] ); ?>

[wp-faq-schema] -

[wp-faq-schema title="Car FAQs"] -

[wp-faq-schema accordion=1] -

[wp-faq-schema title="Car FAQs" accordion=1] -

[ 'post', 'page', 'avada_portfolio' ], 'posts_per_page' => -1, 'post_status' => [ 'publish', 'pending', 'draft', 'private', 'future' ], ] ); $faqs = []; foreach ( $posts as $post ) { $faq_items = get_post_meta( $post->ID, '_wp_faq_schema', true ); if ( ! empty( $faq_items ) ) { foreach ( $faq_items as $faq_item ) { $faqs[] = [ $post->ID, $post->post_title, $faq_item['q'], $faq_item['a'], ]; } } else { $faqs[] = [ $post->ID, $post->post_title, '', '', ]; } } $output = fopen( 'php://output', 'w' ) or wp_send_json_error( __( 'Unable to export as .csv file!', 'wp-faq-schema' ) ); fputcsv( $output, [ 'id', 'title', 'question', 'answer' ] ); foreach ( $faqs as $faq ) { fputcsv( $output, $faq ); } fclose( $output ); die(); } /** * Import FAQs * * @since 2.0.0 * @access public * * @return void */ public function import() { if ( ! isset( $_POST['wfs_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['wfs_nonce'] ), 'wfs_nonce' ) ) { wp_send_json_error( __( 'Unauthorized access!', 'wp-faq-schema' ) ); } $items = ! empty( $_POST['items'] ) ? $_POST['items'] : []; if ( empty( $items ) || ! is_array( $_POST['items'] ) ) { wp_send_json_error( __( 'Empty csv file.', 'wp-faq-schema' ) ); } $items_to_import = []; foreach ( $items as $item ) { if ( empty( $item[0] ) ) { continue; } $id = (int) $item[0]; if ( empty( $items_to_import[ $id ] ) ) { $items_to_import[ $id ] = [ 'title' => $item[1], 'faqs' => [], ]; } $items_to_import[ $id ]['faqs'][] = [ 'q' => $item[2], 'a' => $item[3], ]; } foreach ( $items_to_import as $post_id => $item_to_import ) { $this->import_faq( $post_id, $item_to_import ); } wp_send_json_success( __( 'All FAQs has been imported. Enjoy!', 'wp-faq-schema' ) ); } /** * Import Single Page/Post FAQs * * @since 2.0.0 * @access public * * @param int $post_id Post ID. * @param array $post_data Post Data to import. * @return bool */ public function import_faq( $post_id, $post_data ) { $post = get_post( $post_id ); if ( is_null( $post ) || empty( $post_data['faqs'] ) ) { return false; } return update_post_meta( $post_id, '_wp_faq_schema', $post_data['faqs'] ); } }