0
votes

I've create a custom post type to record data which will be displayed as a list/table on an existing page.

The data does not need to have it's own page. The data will be displayed on an existing page in a table.

I was using Advanced Custom Fields: Repeater but because of the large data set the page was taking a long time to process the data in the admin section.

I've created the custom post, no issues here.

I just don't know how to display the custom post data in an existing template.

 <?php query_posts( array('post_type'=>array('page','Custom_Post_Type'))); ?> 

When I add this code before the loop it display all pages and all custom post types. I just want it to display the individual page + All Custom Post Types

1

1 Answers

1
votes

Try this code, paste it wherever you want the table to be. You have access to all of the post's info inside the loop, not just the title.

$the_query = new WP_Query( array( 'post_type' => 'Custom_Post_Type' ) );

while ( $the_query->have_posts() ) : $the_query->the_post();
    echo '<tr><td>';
    the_title();
    echo '</td></tr>';
endwhile;

wp_reset_postdata();