WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Recent Posts (6 posts)

  1. TerrellKl
    Member
    Posted 7 years ago #

    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?

  2. Chris_K
    Member
    Posted 7 years ago #

    pps: look right BELOW the where you right your post for the section titled "Allowed Markup"

  3. LaPoetessa
    Member
    Posted 7 years ago #

    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.

  4. TerrellKl
    Member
    Posted 7 years ago #

    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

  5. TerrellKl
    Member
    Posted 7 years ago #

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

  6. Chris_K
    Member
    Posted 7 years ago #

    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*

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.