Answers for "get all posts categories"

1

get all posts

$args = array(
  'numberposts' => 10,
  'post_type'   => 'book'
);
 
$latest_books = get_posts( $args );
Posted by: Guest on March-24-2021
0

show all posts from category

<?php
    $args = array( 'category' => 7, 'post_type' =>  'post' ); 
    $postslist = get_posts( $args );    
    foreach ($postslist as $post) :  setup_postdata($post); 
    ?>  
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
    <?php the_excerpt(); ?>  
    <?php endforeach; ?>
Posted by: Guest on January-01-2021

Browse Popular Code Answers by Language