Answers for "wp get posts"

PHP
0

wp_query to get posts

<?php 
$args = array( 
	'post_type'   => 'post',
	'post_status' => 'future'
);
$scheduled = new WP_Query( $args );

if ( $scheduled->have_posts() ) : 
?>
	<?php while( $scheduled->have_posts() ) : $scheduled->the_post() ?>
		<!-- Display Post Here -->
	<?php endwhile ?>
<?php else : ?>
	<!-- Content If No Posts -->
<?php endif ?>
Posted by: Guest on November-02-2020
1

get post by category

<section class="films-tabs pd-40" id="portfolio">

  <?php $film_genres = get_terms('portfolio_cat'); // get all the genres ?>

<div class="container">
<div class="row">
  <!-- Nav tabs -->
  <ul class="nav nav-tabs nav-justified">
    <?php foreach($film_genres as $film_genre) { ?>
      <li>
        <a href="#<?php echo $film_genre->slug ?>" data-toggle="tab"><?php echo $film_genre->name ?></a>
      </li>
    <?php } ?>
  </ul>
</div>
</div>

  <!-- Tab panes -->
  <div class="tab-content">

    <?php foreach($film_genres as $film_genre) { ?>

      <div class="tab-pane" id="<?php echo $film_genre->slug ?>">
        <?php 	
        $args = array(
          'post_type' => 'portfolio',
          'showposts' => -1,
          'orderby' => 'title',
          'order' => 'ASC',
          'tax_query' => array(
            array(
              'taxonomy' => 'portfolio_cat',
              'field' => 'slug',
              'terms' => $film_genre->slug
            )
          )
        );
        $films = new WP_Query( $args );		
        ?>

        <?php if ( $films->have_posts() ) : // make sure we have films to show before doing anything?>
        <div class="table">
            <div class="container">
                <div class="row">
                  <?php while ( $films->have_posts() ) : $films->the_post(); ?>	
                  
                    <div class="table-cont"><a data-fancybox="gallery" href="<?php echo get_the_post_thumbnail_url();?>".><?php the_post_thumbnail() ?></a></div>
                  
                  <?php endwhile; ?>
                  <?php wp_reset_query() ?>
                 </div>
            </div>
        </div>
        <?php endif; ?>

      </div>
    <? }  ?>

  </div><!-- tab-content -->

</section><!-- film-tabs -->
Posted by: Guest on July-21-2020
0

wordpress get posts by type

<?php 

$args = array(
    'post_type'=> 'services',
    'areas'    => 'painting',
    'order'    => 'ASC'
);              

$the_query = new WP_Query( $args );
if($the_query->have_posts() ) : 
    while ( $the_query->have_posts() ) : 
       $the_query->the_post(); 
       // content goes here
    endwhile; 
    wp_reset_postdata(); 
else: 
endif;

?>
Posted by: Guest on September-25-2021

Browse Popular Code Answers by Language