Mohammad Fareed
Mohammad Fareed

Reputation: 1972

Write a Custom Query in Custom Post type Listing

I have created a Custom POST Type with Name "Members"

I want to show the List of submitted records which are submitted at Contact from 7 and Store with contact form advance Database.

is this possible .? my question is I want to create a New Page in Admin in that I want to list out those submissions.

Upvotes: 0

Views: 119

Answers (1)

Ahmed Ginani
Ahmed Ginani

Reputation: 6650

First you did not need to create a new page inside wp-admin if you have created a members CPT , that will automatically appear inside the wp-admin as a custom post type page.

Now you need to migrate the data as I said.

you need to use global $wpdb , Link

Use $myrows = $wpdb->get_results( "SELECT id, name FROM mytable" , ARRAY_A); to get the data from contact form advance database table

Use $wpdb->query("INSERT INTO wp_postmeta ( post_id, meta_key, meta_value) VALUES ('post_id','meta_key','meta_value')"); to insert the data inside wp_post and wp_postmeta tables (I used default prefix)

After this, records will auto appear inside the Members CPT page.

You need to write all the code inside contact form hook like the following ,

add_action( 'wpcf7_before_send_mail', 'my_conversion' );
function my_conversion( $contact_form ) {

}

Upvotes: 1

Related Questions