Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter PH

    (@ph)

    Crud, I can’t even write out my own stuff correctly!

    I want the sidebar to display most recent post of category #2. Should be some sort of simply “get_posts” thing that I haven’t figured out yet.

    I want the main to display last 10 posts from category #1. I have that working, but as you said earlier, I think that my implementation is putting uneeded work on the server.

    So how do you get and display one post from a particular category?

    Thread Starter PH

    (@ph)

    I’ll back up and give a picture of what I am trying to accomplish. Using WP 1.5 and Manji2, I am adding in two modifications to the index.php:

    One, I want to include a section on the top left sidebar that will display the most recent post from category #2, which is just the current day’s devotional text.

    Two, I want the main section to display the last 10 posts from category #2 – our “news” category.

    Here’s what I have so far:

    Thread Starter PH

    (@ph)

    Ah…

    <Sorry – wasn’t trying to run away and hide>

    I understand what you are saying about server load, so let me see if I can get this thing correct. Let me simplify the whole thing for me, which will make it easier for me to understand that basics.

    Let’s say I want to get the most recent post from category #2, and display it on a section of my page. Would this code work:

    <?php
    $my_query = new WP_Query(“category_id=2&showposts=2”);

    while ($my_query->have_posts()) : $my_query->the_post();

    // I add in the code to display the post

    endwhile;
    ?>

    Will that work?

    Thread Starter PH

    (@ph)

    Thanks for the help – I think that I have it figured out correctly now.

    I used the example code from the codex that you pointed out to me – but I had not closed out the “if” statement.

    Again, thanks for the assistance.

    Thread Starter PH

    (@ph)

    Thanks for the link. Here’s what I have in the relevant section of code:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <?php if ( (in_category(‘1’)) ) { ?>

    <div class=”post”>

    …Does all the posting….

    <?php endwhile; else: ?>
    <?php _e(‘Sorry, no posts matched your criteria.’); ?>
    <?php endif; ?>

    But this give me an error. What am I doing wrong?

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