Answers for "blocklab post loop"

PHP
0

blocklab post loop

<?php
  $args = array(
    'post_type' => block_field('post-type', false),
    'posts_per_page' => block_field('num-posts', false),
    /*'tax_query' => array(
  		array(
  			'taxonomy' => block_field('taxonomy-name', false),
  			'field'    => 'slug',
  			'terms'    => block_field('taxonomy-parameter', false),
  		),
  	),*/
    'paged' => 1,
  	'orderby' => 'date',
  	'order'   => 'DESC',
  );

  // The Query
  $the_query = new WP_Query( $args );

  // The Loop
  if ( $the_query->have_posts() ) {
  	while ( $the_query->have_posts() ) {
  		$the_query->the_post();
?>
  
        <!-- WHATEVER... you are in the WP LOOP! -->
        
<?php
  	}
  	/* Restore original Post Data */
  	wp_reset_postdata();
  } else {
  	// no posts found
  	echo "No posts";
  }
   ?>
Posted by: Guest on May-21-2020

Browse Popular Code Answers by Language