Support » Fixing WordPress » Looks right, but doesn't work

  • Resolved lomatic

    (@lomatic)


    I’ve been working on making my own theme/templates and so far everything is looking fine. Looking is the key word.

    I’ve been able to get all of the content where I want by tearing into the basic markup from wp.tutsplus.com and like I said it looks like what I want but…..

    On the index page the page navigation isn’t working correctly. It will navigate forward and back and expected but the page content doesn’t actually change.

    And then, following the instruction from the same site, I copied the same code from index.php to the single.php.

    Here is the code from index.php:

    <?php get_header(); ?>  
    
    <?php /* If there are no posts to display, such as an empty archive page */ ?>
    <?php query_posts('posts_per_page=1');
    if ( have_posts() ) : ?>
    <?php endif; ?>
      <?php while ( have_posts() ) : the_post(); ?>
    
    <div class="post">
            <div id="datetab">
            <p class="date-month"><?php the_time(F); ?></p>
            <p class="date-day"><?php the_time(j); ?></p>
            </div><!-- datetab -->
    
       <div class="post-content"> <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
                <?php the_excerpt(); ?>
        <?php else : ?>
                <?php the_content('Read More','true'); ?>
        <?php endif; ?>
            <div class="post-data">
               <p class="post-details"><a href="<?php the_permalink(); ?>"><strong><?php the_title(); ?></strong></a> | <?php edit_post_link('edit ', '<span class="comment-count">  ' , '</span>'); ?><span class="comment-count"><?php comments_popup_link('fuel the fire', '1 comment', '% comments'); ?></span><?php the_tags(' | Tagged: ',' &times; '); ?></p>
            </div><!-- post data -->
            </div><!-- post content -->
    
        <div class="post-break"></div>
    </div><!-- post -->  
    
    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
            <div class="page-nav">
            <div id="older-posts" class="older"><?php next_posts_link('OLDER'); ?></div><!-- older posts -->
            <div id="newer-posts" class="newer"><?php previous_posts_link('NEWER'); ?></div><!-- newer posts -->
            </div><!-- page-nav -->
    	<div class="clear"></div>
    <?php else: ?>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php get_footer(); ?>

    I’m fully prepared and expecting there to be errors, the weird thing is that it all displays correctly except on the single.php where the comments.php file isn’t being pulled in…

    Here’s that code:

    <?php get_header(); ?>  
    
    <?php /* If there are no posts to display, such as an empty archive page */ ?>
    <?php query_posts('posts_per_page=1');
    if ( have_posts() ) : ?>
    <?php endif; ?>
      <?php while ( have_posts() ) : the_post(); ?>
    
    <div class="post">
            <div id="datetab">
            <p class="date-month"><?php the_time(F); ?></p>
            <p class="date-day"><?php the_time(j); ?></p>
            </div><!-- datetab -->
    
       <div class="post-content"> <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
                <?php the_excerpt(); ?>
        <?php else : ?>
                <?php the_content('Read More'); ?>
        <?php endif; ?>
            <div class="post-data">
               <p class="post-details"><strong><?php the_title(); ?></strong> | <?php edit_post_link('edit ', '<span class="comment-count">  ' , '</span>'); ?><span class="comment-count"><?php comments_popup_link('fuel the fire', '1 comment', '% comments'); ?></span><?php the_tags(' | Tagged: ',' &times; '); ?></p>
            </div><!-- post data -->
            </div><!-- post content -->
    
        <div class="post-break"></div>
    </div><!-- post -->  
    
    <?php comments_template( '', true ); ?>
        <?php endwhile; ?>
    <?php get_footer(); ?>

    Any help or insight would be great!

    Here’s a screen cap

Viewing 3 replies - 1 through 3 (of 3 total)
  • For the pagination, you must include the ‘paged’ argument to the query:

    <?php
    $paged = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : ((intval(get_query_var('page'))) ? intval(get_query_var('page')) : 1);
     query_posts("posts_per_page=1&paged=$paged");
    if ( have_posts() ) : ?>

    Can’t spot why comments aren’t working.

    Thread Starter lomatic

    (@lomatic)

    I had seen that in another topic and tried my best, but could not, for the life of me, get it to work.

    Thank you!

    Thread Starter lomatic

    (@lomatic)

    I figured it out. I started removing snippets and when I removed this
    <?php query_posts('posts_per_page=1');
    from the the single.php and page.php everything is now working.

    So now it’s just:
    <?php if ( have_posts() ) : ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Looks right, but doesn't work’ is closed to new replies.