WordPress.org

Ready to get started?Download WordPress

Forums

Display all custom post types on a static page (1 post)

  1. visualize
    Member
    Posted 2 years ago #

    Hey there,

    how do i display alle of my custom post types titles (cpt1, cpt2) on a static page?

    im able to do it for either cpt1 or cpt2 but not all of them together.. im trying with that piece of code..

    <?php
    
    	// The Query
    	$query = new WP_Query( array( 'post_type' => array( 'cpt1', cpt2' ) ) );
    
    	// The Loop
    	while ( $query->have_posts() ) : $query->the_post();
    	echo '<li>';
    		the_title();
    	echo '</li>';
    	endwhile;
    
    	// Reset Post Data
    	wp_reset_postdata();
    
     ?>

    any ideas on that?
    thx..

Topic Closed

This topic has been closed to new replies.

About this Topic