WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Weird problem with the_content and the_category (1 post)

  1. Tijmen
    Member
    Posted 8 years ago #

    So I thought I had made myself a nice little box on a single entry page where related posts (ie. same category) and posts from the same author show up.

    Not so much.

    After I inserted the following, odd stuff started to happen. The text of the post and the categories which I have below my post are suddenly all the same. That is, they're the text categories of the last post which is shown in the box with the post from the same author.

    So, evidently, somehow WP gets confused, and the_content and the_category don't show the stuff from the page it's on, but something else.

    Can anybody help? Thanks!

    <?php
    $cat = get_the_category();
    $cat = $cat[0];
    $posts = get_posts("category=" . $cat->cat_ID . "&numberposts=5");
    if( $posts ) :
    ?>
    <div class="meerhierover">
    <ul>
    <li><h3>meer in categorie <?php
    $cat = get_the_category(); $cat = $cat[0]; echo $cat->cat_name;
    ?>:</h3></li>
    <?php foreach ( $posts as $post ) : setup_postdata( $post ); ?>
    <?php if ($post->ID != $p) { ?>
    <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_time('d/m'); ?>: <?php the_title(); ?></a></li>
    <?php } ?>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>

    <?php
    $aut = the_author('', FALSE);
    $aut = $cat[0];
    $posts = get_posts("the_author=" . $aut->aut_ID . "&numberposts=5");
    if( $posts ) :
    ?>
    <ul>
    <li><h3>meer door <?php the_author(); ?>:</h3></li>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <?php if ($post->ID != $p) { ?>
    <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_time('d/m'); ?>: <?php the_title(); ?></a></li>
    <?php } ?>
    <?php endforeach; ?>
    </ul>
    </div>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic