Support » Themes and Templates » Strange behaviour

  • I’m still working on my new WordPress site. It’s almost ready to launch, but I’ve run into a couple of problems which I just can’t explain logically. Any help would be greatly appreciated.

    The website is at

    Here they are:

    Recent posts stopped working

    I want to return the 2 newest posts when in single post mode, but exclude the current post. And I did it. The problem is, it just stopped working. It didn’t change the code and it stopped on the server as well as on my localhost.

    Here’s the code:

    <section id='recent_posts'>
                <header class='recent_header'>
                    Recent posts
                    $id = $post->ID;
                    $recent_posts = wp_get_recent_posts("numberposts=2&exclude=$id");
                    foreach( $recent_posts as $recent ) { ?>                        
                        <article class='single_recent'>
                                <a href="<?php echo get_permalink($recent["ID"]); ?>"><?php echo $recent["post_title"]; ?></a>
                                <?php echo get_excerpt_by_id($recent["ID"]); ?>
                <?php } ?>

    the_author() empty only on index.php when not logged in

    I have two different ways to load posts. One is in index.php and another one is in loop.php. The first one loads the first 4 posts, the latter loads more posts when scrolling down or clicking on the “load more” button. Both are inside the loop.

    The code is THE SAME, but index.php doesn’t show anything when I call the_author, when a user is not logged in. When I’m logged in, I see the author name all the time and when logged out, I only see the name on newly loaded posts.

    have_comments() returns false [with comments_template()]

    I just copied the code for the comments template and the 3 functions from this tutorial and it doesn’t work.

    I found a solution that says I should call the template with comments_template() instead of the general include method and that is how I do it. It still doesn’t show a single comment, even though get_comments_number() returns 2 and I see the comments in the dashboard.

  • The topic ‘Strange behaviour’ is closed to new replies.