Forum Replies Created

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

    (@pgmccullough)

    Okay–well, I got this working how I wanted, but probably in the most unnecessarily convoluted way possible. Surely there’s got to be a more efficient way! At any rate, if anyone else finds themselves at a loss as to how to do this, here’s what I managed to come up with.

    First, we summon the main post with a basic loop. While in the loop, we find out what the post id of the main post is:

    <?php ($current = get_the_id()) ?>

    Now comes the funny stuff. I get a full list of all the posts I have in the given category (I wanted the previous post in the same category). This gives me an array of post ids. I then run a check that basically looks through each post id and checks to see if it matches the post id we pulled from the main post. If it is, we tell it to grab the following post id in the array.

    <?php $counter = 1; ?>
    <?php
    global $post;
    $args = array( 'numberposts' => 100, 'offset'=> 0, 'category' => 9 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) : setup_postdata($post); ?>
    <?php ($nextpost[$counter] = get_the_id()); ?>
    <?php $counter++; ?>
    <?php endforeach; ?>
    <?php ($hwmnypsts = count($nextpost)); ?>
    <?php $countsy = 1; ?>
    <?php while($countsy <= $hwmnypsts) : ?>
    <?php if ($nextpost[$countsy] == $current) {
    $countsy++;
    $next = $nextpost[$countsy];
    } else {
    $countsy++;
    } ?>
    <?php endwhile; ?>

    now that we’ve got the next post id, we just have to call the post up:

    <?php $last_query = new WP_Query('p=' . $next);
      while ($last_query->have_posts()) : $last_query->the_post(); ?>

    And finally, I through in a little extra to make sure that if there is no next post id (as in, we’re looking at the earliest post), it doesn’t load a next post.

    I did that by simply surrounding the content of the second post with:

    <?php if (isset($next)) : ?>

    Hope someone else is able to use this!

    pgmccullough

    (@pgmccullough)

    exact same problem for me. I tried moving the xml file, which was indeed in the uploads folder. But it didn’t make any difference. Anything?

    Thread Starter pgmccullough

    (@pgmccullough)

    Thanks – neither option seems to help the situation though

    I am having the exact same problem. Benbt-japan – could you elaborate on exactly where to stick:

    if ($xxx=’id-‘) { $xxx=’ID’; }

    Thanks so much.

    Thread Starter pgmccullough

    (@pgmccullough)

    Thanks for the heads up on Firefox. I fixed the footer overlap thing, and now since it’s all readable, I’m not going to bother with the chunk being cut off and the border not showing up.

    None of the validator stuff that’s showing up seems to affect my original problem. Is this not something that anyone else has encountered??

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