Darfuria
Member
Posted 1 year ago #
I'm using my category.php to select the post title "home" in the current category.
<?php
$currentcat = the_category_ID();
$query = 'cat=' . $currentcat . '&name=home&showposts=1';
?>
<?php query_posts($query); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
?>
However, this seems to select the latest post from any category titled home. Echoing $currentcat returns the correct category ID.
Any help appreciated.
Try this instead:
<?php
$cat = get_query_var('cat');
query_posts("cat=$cat&name=home&showposts=1");
?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
Darfuria
Member
Posted 1 year ago #
Hi there, thanks for the response.
Unfortunately that's displaying the same post in both categories.
I have "Home" posted in General (for example) and "Home" posted in News.
Going to site/home/ displays the "Home" post in General, and going to site/news/ displays the "Home" post in General too.