Created
February 17, 2015 09:38
-
-
Save schalkburger/c6bd92fbefc2ad54b79e to your computer and use it in GitHub Desktop.
Wordpress list posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (is_page()) { | |
$cat=get_cat_ID($post->post_title); // Use page title to get a category ID | |
$posts = get_posts ("cat=$cat&showposts=3"); // Show 3 posts | |
if ($posts) { | |
foreach ($posts as $post): | |
setup_postdata($post); ?> | |
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> | |
<?php the_excerpt(); ?> | |
<?php endforeach; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment