• Resolved mmikeyy

    (@mmikeyy)


    I’m trying to find a solution for the following problem:
    I want my frontpage to show only 1 post from a specific category.
    This is easily achieved by the following code:

    if (have_posts()) :
    $my_query = new WP_Query('cat=1&showposts=1');
    while ($my_query->have_posts()) : $my_query->the_post();

    But everything else is messed up now. Doesn’t matter which tag I click from my tag cloud it keeps showing the same page over again. And whenever I try to search for something it just shows me the frontpage.

    So I thought I’d build an if/else construction that fetches the current url and checks if it is the frontpage, or maybe if there are some parameters. If there are parameters it should alter the query to the default loop. If there aren’t any parameters it would clearly be the frontpage and it should use the altered loop.
    But I can’t figure out how to make a working if/else construction for this.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Single post without messing up the categories’ is closed to new replies.