wp_query custom post type

  <?php    
  	   $args = array(  
      'post_type' => 'custom_type',
      'post_status' => 'publish',
      'posts_per_page' => 8, 
      'orderby' => 'title', 
      'order' => 'ASC', 
          );

  $loop = new WP_Query( $args ); 

  while ( $loop->have_posts() ) : $loop->the_post(); 
      print the_title(); 
      the_excerpt(); 
  endwhile;

  wp_reset_postdata(); 
  ?>

3
4
Phoenix Logan 186120 points

                                    &lt;?php
$args = array(
&nbsp;&nbsp;&nbsp;&nbsp;'post_type'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =&gt; 'product',
&nbsp;&nbsp;&nbsp;&nbsp;'posts_per_page' =&gt; 10,
);
$loop = new WP_Query($args);
while ( $loop-&gt;have_posts() ) {
&nbsp;&nbsp;&nbsp;&nbsp;$loop-&gt;the_post();
&nbsp;&nbsp;&nbsp;&nbsp;?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&quot;entry-content&quot;&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php the_title(); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php the_content(); ?&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;
&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
}

3 (4 Votes)
0
0
2
Awgiedawgie 440220 points

                                    //WordPress: Query a custom post type
//For example, query all Case Study post types

&lt;?php query_posts('post_type=case_studies'); ?&gt;

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
query custom post type get custom posty type query wp_query custom post type id wp_query custom post type category wordpress query of post type wordpress query post custom type wp get custom post types wp_query get post by post type custom post type wordpress post query custom post type get custom post type wp_query post type query wp get custom post type popular post query custom post type wordpress wordpress query to get posts of custom posttype wp query for post type get custom post type query query custom post type wordpress wp_query custom post wordpress query post type wordpress get custom post type query to get all custom post type posts wordpress wp get custom post type category wordpress query post type custom field value wp query post type wp query get custom post type wordpress php query for custom post type wp_query post type wordpress php custom post type query wp get posts custom post type query_posts custom post type query custom post type wp wp_query get custom post type wp query custom post type wp_query for custom post type wp_query all post for type post type wp query wp query post types all items wordpress get custom post type posts wordpress query on customer post type wordpress php query custom post type custom post type query wordpress wordpress query posts custom post type query get custom post type how to print the custom post type wp_query custom post type get custom post type wordpress wp query get post types wordpress query for custom post type wordpress custom post type query wordpress query custom post type wordpress set query post type custom post type loop post type query wordpress
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source