Skip to content

Instantly share code, notes, and snippets.

@tisuchi
Last active January 12, 2018 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tisuchi/ff764c72ff421741a6ed7d91245b1fda to your computer and use it in GitHub Desktop.
Save tisuchi/ff764c72ff421741a6ed7d91245b1fda to your computer and use it in GitHub Desktop.
Wordpress show all posts of a category
<?php
$args = array( 'category' => 1, '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; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment