Forums

Post from othe category in sidebar (2 posts)

  1. absenso
    Member
    Posted 4 years ago #

    I'm quite new in wordpress usage.
    I'm trying to create for my template a left sidebar showing 2 posts of a different category with images called trough custom fields. I do it using query_posts command, and works fine in homepage. But in the categories archive pages, it gives a "not found", probably bacause i thinks to be still in the category of the sidebar. If i use query_posts again to call a category everything works again but, as i have many categories, i'd like to call the current category dinamically.
    This is driving me crazy!!!

    Thanks in advance.

  2. absenso
    Member
    Posted 4 years ago #

    Maybe could be useful add some code:

    Here i call the category in the sidebar

    <?php query_posts('showposts=2&cat=20'); ?>
    <li>
    <?php while (have_posts()) : the_post(); ?>
    <div class="classname"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">

    here i call the image from the custom field
    <img src="<?php bloginfo('template_url'); ?>/images/<?php $values = get_post_custom_values("Case"); echo $values[0]; ?>" alt="" /></a>

    here i call the titles

    <a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?>&raquo;</a></div>
    <?php endwhile; ?>
    </li>

    After this is needed some code to tell that we are not in cat=20, but in the real current category, but i found no solutions.

    Please, i really need help!

Topic Closed

This topic has been closed to new replies.

About this Topic