0

Suppose Your post type slug is cars :

Code For Display Posts At Page Template:

<?php /* Template Name: cars  */ 
get_header();

$args = array(
            'post_type' => 'cars',
            'post_status' => 'publish',
            'order' => 'ASC'
);?>
<table>
    <tr>
        <th>Name</th>
        <th>Image</th>
    </tr>
<?php   

$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();?>

    <tr>
         /*for display post Title*/
        <td><?php the_title(); ?></td>
        /*for display posts Thumbnail*/
        <td><?php the_post_thumbnail( 'medium' ); ?></td>
    </tr>

<?php endwhile;endif;?>

</table>

<?php wp_reset_postdata();?>

Note: pastle this to new created file in active themes folder save it and select template after created page in back end of WordPress
I Hope this will Help :)

3
  • WordPress Stack Exchange! Please explain what your question is.
    – fuxia
    Dec 22, 2021 at 9:37
  • This is a question for me before 3 month and i search whole internet but i didn't found that's why i think today when i know the answer i should post that's why i posted. Dec 23, 2021 at 5:26
  • Then post question and answer as separate posts. This way you might even get a better answer, which filtering pre_get_posts, not a new query. :)
    – fuxia
    Dec 23, 2021 at 7:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.