Jump to content

[WP] the_author doesn't work as it should


Grandioso

Recommended Posts

Is there a reason why the_author should return an empty string on the first page when the user is not logged in, but return the author name just as it should when more posts are loaded through AJAX ? The loop is the same in both cases. Please help me resolve this issue as I'm clueless and I need it fixed ASAP to launch my site.

 

Here's the whole index.php:

 

<?php 

get_header();
get_sidebar();

?>
<!-- MAIN DIV -->

            <div id='content_and_floater'>

                <?php get_template_part('social_floater'); ?>
                <div id='content'>
                    <?php get_template_part('loop'); ?>
                </div>

            </div>

            <?php get_template_part('loader'); ?>

<!-- MAIN DIV -->
<?php
get_footer();
?>

 

And here's how the infinitePaginator calls the loop in functions.php (the function is called when scrolled down to the bottom or the loader link is clicked):

 

function wp_infinitepaginate(){
    $loopFile        = $_POST['loop_file'];
    $paged           = $_POST['page_no'];
    $posts_per_page  = get_option('posts_per_page');  

    # Load the posts
    query_posts(array('paged' => $paged ));
    get_template_part( $loopFile );  

    exit;
}

 

You can see the behaviour at test.nowillnoskill.net. In single posts it's not working either. My guess is that query_posts(array('paged' => $paged )); changed something in the query, but I don't know what is it. I tried to insert setup_postdata($post); just after the_post() in loop.php as I found that worked for someone, but it doesn't for me.

 

Here is my loop.php:

 

<?php while ( have_posts() ) : the_post() ?>    
            <!-- POST1 -->
            <article class='post'>  
                <header class='post_header'>

                    <?php
                        global $current_user;
                        $current_user = wp_get_current_user();
                        if (!empty($current_user)) {
                            $pid = get_the_id();
                            $uid = $current_user->ID;

                            $title = (is_favorite($pid, $uid)) ?
                                'Remove from favorites' :
                                'Add to favorites';

                            $trans = (is_favorite($pid, $uid)) ?
                                '' :
                                ' transparent';

                    ?>

                    <div>
                        <h2>
                            <a href="<?php the_permalink(); ?>">
                                <?php the_title(); ?>
                            </a>
                        </h2>

                        <?php if (is_user_logged_in()) { ?>
                        <a title='<?php echo $title ?>' class='post_favorite' href='#' alt='fpid=<?php echo $pid ?>uid=<?php echo $uid ?>'>
                            <span class='symbol<?php echo $trans ?>'>R</span> 
                        </a>
                        <?php } ?>

                    </div>

                    <div class='post_header_div'>

                        <strong class='post_category'>
                            <?php echo get_the_category_list(', '); ?>
                        </strong>

                        <strong class='post_author'>
                            <span class='symbol'>U</span>
                                <?php the_author(); ?>
                        </strong>

                    </div>

                    <div>

                        <span class='post_author'>
                            <?php edit_post_link('[edit]'); ?>                          
                        </span>

                    </div>

                    <?php } ?>

                </header>

                <figure class='post_image'>
                    <!--<img src='design/img/flashkick.png' alt='logo' />-->
                    <?php the_post_thumbnail(); ?>
                </figure>

                <div class='post_perex'>
                    <?php the_content('Read more'); ?>
                </div>

                <div class='space'></div>

                <footer class='post_footer'>

                    <div class='post_footer_top'>

                        <div class='post_tags'>
                            <?php the_tags('', '', ''); ?>
                        </div>

                        <div class='post_time'>
                            <time datetime="<?php the_time('Y-m-d'); ?>" pubdate>
                                <span class='symbol'>P </span>
                                    <?php relative_post_the_date(); ?>
                            </time>

                        </div>

                    </div>

                </footer>

                <div class='space'></div>

            </article>

            <?php endwhile; ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.