category_name as variable
-
Hey all,
First time poster, long time reader. I’ve been digging into custom sidebars, and am hitting a wall.
I’m trying to have posts appear in a sidebar based on the category. The category is the page name. So if I have a news page, I’ve made a category: “news”, and created posts with this category checked off.
Now I want these to appear on the page: news. I would think this would work:
<?php $pagetitle = wp_title(”, false); ?>
<?php query_posts(‘category_name=$pagetitle&showposts=10’); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_content(‘read more’); ?>
<?php endwhile;?>But the $pagetitle variable doesn’t get replaced. If I hard-code a category here (which are also page titles), it works fine. But that forces me to repeat the code for ALL my pages! Yikes!
Any help appreciated.
seej
- The topic ‘category_name as variable’ is closed to new replies.