Get posts based on page title?
-
I’ve created a page template for a blog that will use that template for over 100 pages. I have the template pulling information based on page title, ie: <?php the_title(); ?>.jpg
I would like the template to display the latest posts from a category of the same name as the page. So, if the page was named “Kittens” I would like it to display stories from the “Kittens” category. Here is the code I’m trying:
<h3>Recent Stories</h3> <?php $recent = new WP_Query("cat=<?php the_title(); ?>&showposts=2"); while($recent->have_posts()) : $recent->the_post();?>
WP doesn’t appear to be recognizing the code after “cat=” Does anyone know of a way to do this?
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Get posts based on page title?’ is closed to new replies.