• 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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; ?>

    Thread Starter Darfuria

    (@darfuria)

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘select home post in current category’ is closed to new replies.