Forums

Post by Catergory (2 posts)

  1. Drossie
    Member
    Posted 11 months ago #

    Just wondering if anyone could tell me how to make the following code display posts of only the current catergory. At the moment it displays post from all catergories.

    "
    <?php $catergory = new WP_Query(cat_id=current_catergory); while($catergory->have_posts()) : $catergory ->the_post(); ?>

    <?php if( get_post_meta($post->ID, "homethumb", true) ): ?>
    " rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "homethumb", true); ?>" alt="<?php the_title(); ?>" />
    <?php else: ?>
    " rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" />
    <?php endif; ?>
    <b>" rel="bookmark"><?php the_title(); ?></b>
    <?php the_content_limit(350, "[Read more]"); ?> "

  2. filosofo
    Member
    Posted 11 months ago #

    Instead of

    $catergory = new WP_Query(cat_id=current_catergory);

    you want

    $catergory = new WP_Query("cat=$current_category");

    where $current_category holds the integer id of the desired category.

    By the way, I'd fix the misspelling of $catergory just because it's likely to confuse things later.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.