Answers for "custom post type loop"

PHP
0

wp loop custom post type

<?php
$loop = new WP_Query(
    array(
        'post_type' => 'yourposttypehere' // This is the name of your post type - change this as required,
        'posts_per_page' => 50 // This is the amount of posts per page you want to show
    )
);
while ( $loop->have_posts() ) : $loop->the_post();
// The content you want to loop goes in here:
?>
 
<div class="col-sm-4">
My column content
</div>
 
<?php endwhile;
wp_reset_postdata();
?>
Posted by: Guest on June-04-2020
0

custom post type loop with category

// using category slug
 $args = array(  
          'post_type' => 'produto', 
          'posts_per_page' => -1, 
          'tax_query' => array(
            array(
                'taxonomy' => 'produto_category',
                'field'    => 'slug', // term_id, slug  
                'terms'    => 'taeq',
            ),
           )
         );

// using category id
/* $args = array(  
          'post_type' => 'produto', 
          'posts_per_page' => -1, 
          'tax_query' => array(
            array(
                'taxonomy' => 'produto_category',
                'field'    => 'term_id', // term_id, slug  
                'terms'    => 5,
            ),
           )
         );

*/ 

$loop = new WP_Query($args);
Posted by: Guest on October-05-2020
0

wp_query custom post type

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

<?php query_posts('post_type=case_studies'); ?>
Posted by: Guest on January-14-2020
0

custom post type query loop wordpress

Custom Post Type Query Loop
Posted by: Guest on December-07-2020

Code answers related to "custom post type loop"

Browse Popular Code Answers by Language