• Resolved terrellkl

    (@terrellkl)


    On my blog i have it where it checked to see which category you’re in and lists posts from that category under Recent Posts.

    <li><h2>
    <?php
    if ((!is_home()) & (!in_category(8)) & (!in_category(1))) {
    _e('Recently Answered'); ?></h2>

    <ul>
    <?php $categoryvariable=$cat; // assign the variable as current category
    $query= 'showposts=5&cat=' . $categoryvariable. '&orderby=date&order=ASC'; // concatenate the query
    query_posts($query); // run the query
    ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <li><a>"><?php the_title() ?> </a> </li>
    <?php endwhile; endif; ?>
    </ul>
    </li>
    <?php } ?>

    The conditions I’m trying to make are that if you’re not on your home page in categories 8 or 1, display Recently Posted Posts From the category you are viewing. But when I select a specific post ie. http://**/wordpress/?p=9 it displays new posts from every category. It only does this on specific posts pages. How can I fix this?

    PS: How the heck do you use the Markup to format code on this bloody forum?

Viewing 5 replies - 1 through 5 (of 5 total)
  • pps: look right BELOW the where you right your post for the section titled “Allowed Markup”

    It’s years since I did any programming, and I am not familiar with whatever language you are using here, but even so there must be errors on the syntax of this if it does not work. Either that or your LOGIC statement is way off mark.

    Thread Starter terrellkl

    (@terrellkl)

    Well I see the problem
    when viewing single posts the variable $cat is not set, is there anyway to pull the category from the currently viewed post?

    Thanks

    Thread Starter terrellkl

    (@terrellkl)

    I got it..
    Not much help ya know..

    Glad to see you got it working.

    On average, there are 185+ posts a day here. With a very small number of unpaid volunteers to do their best at handling them.

    Anyone can be a volunteer…. *hint*

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

The topic ‘Recent Posts’ is closed to new replies.