Forum Replies Created
-
AuthorPosts
-
Robert Feddes
ParticipantHaving the same problem
Robert Feddes
ParticipantIt is solved, what was lacking was adding a query loop type: users to the div above!
Added the query loop and now it works!
May 8, 2022 at 10:51 PM in reply to: MB View shortcode including the CPT to pull the field contents from #35956Robert Feddes
ParticipantThanks Long Nguyen,
If I were smart enough to understand the documentation that would be great, but I am not.
So please help me out, how do I do that?
The CPT slug is: content-ctas
The view short code is: [mbv name="cta-rugpijn"]
The post ID of one of the cta's is 2501, so please tell me, what must the shortcode then be?
[mbv name="cta-rugpijn" ??="2501"]????
Thanks!
Robert Feddes
ParticipantHi Long
I added that code to code snippets, but that did not work, apparently oxygen needs different code, can you test that please?
Thanks
Robert
Robert Feddes
ParticipantI tried your instructions on: https://metabox.io/move-custom-fields-data-to-custom-tables/
But I am on oxygen builder, so am wondering how to do this.
I tried the following code and added it to a code snippet, and also tried it as a separate plugin, but no luck at all.
Help MUCH appreciated
function oxygen_child_data_testimonials() { if ( empty( $_GET['move-data-testimonials'] ) || ! current_user_can( 'manage_options' ) ) { return; } $paged = isset( $_GET['oxygen-child-paged'] ) ? $_GET['oxygen-child-paged'] : 0; $paged += 1; $url = add_query_arg( 'oxygen-child-paged', $paged, 'https://www.rugpijnweg.nl/wp-admin/?move-data-testimonials=1' ); $posts = oxygen_child_admin_records_get_testimonials( $paged ); if ( empty( $posts ) ) { die( 'Done' ); } foreach ( $posts as $post ) { oxygen_child_move_data_testimonials( $post ); } echo " <script> setTimeout( () => { window.location.href = '$url'; }, 3000 ); </script> "; die; } add_action( 'admin_init', 'oxygen_child_data_testimonials' ); function oxygen_child_admin_records_get_testimonials( $paged = 1 ) { $args = [ 'post_type' => 'reviews', 'posts_per_page' => 100, 'paged' => $paged, 'fields' => 'ids', 'orderby' => 'ID', ]; $query = new WP_Query( $args ); return $query->posts; } function oxygen_child_move_data_testimonials( $post_id ) { global $wpdb; echo 'Migrating Reviews ', $post_id, '<br>'; $data = []; $data['ID'] = $post_id; $data['testie_title'] = get_post_meta( $post_id, 'testie_title', true ); $data['testie_description'] = get_post_meta( $post_id, 'meta_description', true ); $data['testie_sandwich_link_text'] = get_post_meta( $post_id, 'testie_sandwich_link_text', true ); $data['testie_linkto_text'] = get_post_meta( $post_id, 'testie_linkto_text', true ); $data['testie_header'] = get_post_meta( $post_id, 'testie_header', true ); $data['testie_slogan'] = get_post_meta( $post_id, 'testie_slogan', true ); $data['testie_text'] = get_post_meta( $post_id, 'testie_text', true ); $data['testie_name'] = get_post_meta( $post_id, 'testie_name', true ); $data['testie_key'] = get_post_meta( $post_id, 'testie_key', true ); $data['testie_rating'] = get_post_meta( $post_id, 'testie_rating', true ); $data = array_filter( $data ); if ( $data ) { $wpdb->insert( 'wp_custom_testies', $data ); } $meta_key_array = [ 'testie_title', 'testie_description', 'testie_sandwich_link_text', 'testie_linkto_text', 'testie_header', 'testie_text', 'testie_name', 'testie_key', 'testie_rating', ]; $meta_key = "'" . implode( "','", $meta_key_array ) . "'"; $wpdb->query( $wpdb->prepare( " DELETE FROM wpqq_postmeta WHERE post_id = %d AND meta_key IN ( $meta_key )", $post_id ) ); }Robert Feddes
ParticipantI have tried the following code, adapted from your website:
function oxygen_child_data_testimonials() { if ( empty( $_GET['move-data-testimonials'] ) || ! current_user_can( 'manage_options' ) ) { return; } $paged = isset( $_GET['oxygen-child-paged'] ) ? $_GET['oxygen-child-paged'] : 0; $paged += 1; $url = add_query_arg( 'oxygen-child-paged', $paged, 'https://www.rugpijnweg.nl/wp-admin/?move-data-testimonials=1' ); $posts = oxygen_child_admin_records_get_testimonials( $paged ); if ( empty( $posts ) ) { die( 'Done' ); } foreach ( $posts as $post ) { oxygen_child_move_data_testimonials( $post ); } echo " <script> setTimeout( () => { window.location.href = '$url'; }, 3000 ); </script> "; die; } add_action( 'admin_init', 'oxygen_child_data_testimonials' ); function oxygen_child_admin_records_get_testimonials( $paged = 1 ) { $args = [ 'post_type' => 'reviews', 'posts_per_page' => 100, 'paged' => $paged, 'fields' => 'ids', 'orderby' => 'ID', ]; $query = new WP_Query( $args ); return $query->posts; } function oxygen_child_move_data_testimonials( $post_id ) { global $wpdb; echo 'Migrating Reviews ', $post_id, '<br>'; $data = []; $data['ID'] = $post_id; $data['testie_title'] = get_post_meta( $post_id, 'testie_title', true ); $data['testie_description'] = get_post_meta( $post_id, 'meta_description', true ); $data['testie_sandwich_link_text'] = get_post_meta( $post_id, 'testie_sandwich_link_text', true ); $data['testie_linkto_text'] = get_post_meta( $post_id, 'testie_linkto_text', true ); $data['testie_header'] = get_post_meta( $post_id, 'testie_header', true ); $data['testie_slogan'] = get_post_meta( $post_id, 'testie_slogan', true ); $data['testie_text'] = get_post_meta( $post_id, 'testie_text', true ); $data['testie_name'] = get_post_meta( $post_id, 'testie_name', true ); $data['testie_key'] = get_post_meta( $post_id, 'testie_key', true ); $data['testie_rating'] = get_post_meta( $post_id, 'testie_rating', true ); $data = array_filter( $data ); if ( $data ) { $wpdb->insert( 'wp_custom_testies', $data ); } $meta_key_array = [ 'testie_title', 'testie_description', 'testie_sandwich_link_text', 'testie_linkto_text', 'testie_header', 'testie_text', 'testie_name', 'testie_key', 'testie_rating', ]; $meta_key = "'" . implode( "','", $meta_key_array ) . "'"; $wpdb->query( $wpdb->prepare( " DELETE FROM wpqq_postmeta WHERE post_id = %d AND meta_key IN ( $meta_key )", $post_id ) ); }But nothing happens
Robert Feddes
ParticipantI am using wp all import pro but when I import only the title gets imported, non of the custom fields are imported
How can I do this?
-
AuthorPosts