WordPress.org

Ready to get started?Download WordPress

Forums

Older And Newer Posts Not Working (13 posts)

  1. iselltheta
    Member
    Posted 3 years ago #

    I have the following code in my index.php file

    <li><?php next_posts_link('&laquo; Older Entries') ?></li>
    			<li><?php previous_posts_link('Newer Entries &raquo;') ?></li>

    Problem I am having is on my home page for example (http://macrostory.com) I have the admin setting to show 25 posts but I have about 500 posts. All you see are the 25 but at the bottom of the page there is no link for previous or newer posts. Same happens with search or sort by category or by date.

    Can someone help me understand what I need to do to fix this. Thank You!

  2. you didn't describe where exactly you have the code section for hte 'next/prev posts' - can you paste the full code of index.php into a http://pastebin.com/ and post the link to it here?

  3. iselltheta
    Member
    Posted 3 years ago #

    Hi - the file is rather small (index.php) so let me try and paste it here. Thank You -

    [code moderated per forum rules - please use the pastebin for any code longer than 10 lines]

  4. the section:

    <?php /*
            <ul>
    <li><?php next_posts_link('&laquo; Older Entries') ?></li>
    			<li><?php previous_posts_link('Newer Entries &raquo;') ?></li>
    		</ul>
    		*/ ?>

    is commented by using /* .... */, i.e. will not be shown;

    remove /* and */

    or install the wp-pagenavi plugin

  5. iselltheta
    Member
    Posted 3 years ago #

    I removed those two as you said and then got a syntax error. Any other thoughts or did I misunderstand what you said (I removed /* and */ with no other changes). Thanks

  6. my bad - should have checked it properly :-(

    try to remove <?php /* and */ ?>

    so the section would look like:

    <ul>
    <li><?php next_posts_link('« Older Entries') ?></li>
    			<li><?php previous_posts_link('Newer Entries »') ?></li>
    		</ul>
  7. iselltheta
    Member
    Posted 3 years ago #

    We are getting there. No syntax error, site looked the same though with no reference to newer entries or older entries. I look at my home page where it is set to 25 posts (again I have 500) and all I see are the 25 and at the bottom no reference to newer or older entries.

    Thanks for your patience.

  8. can you re-paste the code of index.php (as it is now) into a http://pastebin.com/ and post the link to it here?

    also, does your theme hava a home.php?

  9. iselltheta
    Member
    Posted 3 years ago #

    I'm not familiar with paste bin so I'll try here. And there is a header.php file. Thank You -

    <?php get_header(); ?>
    
    <div id="columns">
      <div id="centercol">
        <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
        <div class="box post" id="post-<?php the_ID(); ?>">
    <?php global $more; $more = 0; ?>
          <div class="content">
            <div class="post-title">
              <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                <?php the_title(); ?>
                </a></h2>
            </div>
            <!--/post-title -->
            <?php $postimageurl = get_post_meta($post->ID, 'post-img', true); if ($postimageurl) { ?>
            <div class="pic"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><img src="<?php echo $postimageurl; ?>" alt="<?php the_title_attribute(); ?>" /></a></div>
            <?php } ?>
            <!--/post-img -->
            <div class="social-links fl">
              <div style="padding:0 0 15px 0;"><span>
                <?php the_time('jS'); ?>
                </span></div>
              <div class="post-date">On
                <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></p>
                <br />
                In
                <?php the_category(', ') ?>
                <br />
                by
                <?php the_author_posts_link(); ?>
                <div class="post-commets">
                  <?php _e('Comments'); ?>
                  <a href="<?php the_permalink(); ?>" title="View <?php _e('Comments'); ?>" class="font-sm">(
                  <?php comments_number(0, 1, '%'); ?>
                  )</a></div>
              </div>
              <!--/post-date -->
              <div class="clr"></div>
            </div>
            <!--/social-links -->
    <?php
    global $more;
    $more = 0;
    ?>
    
            <div class="content">
    
    <?php the_content(); ?>
              <!--/post-comments -->
              <p><span><?php _e('Leave Your'); ?> <a href="<?php the_permalink(); ?>" title="<?php _e('Leave Your'); ?> Response"><?php _e('Comments'); ?></a> &raquo;</span></p>
            </div>
            <!--/post-excerpt -->
            <div class="clr"></div>
          </div>
          <!--/content -->
        </div>
        <!--/box -->
        <?php endwhile; ?>
        <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
    
    <ul>
    <li><?php next_posts_link('« Older Entries') ?></li>
    			<li><?php previous_posts_link('Newer Entries »') ?></li>
    		</ul>
    
        <?php else : ?>
        <div class="box post">
          <div class="content">
            <div class="post-title">
              <h1>No Posts Were Found</h1>
            </div>
          </div>
        </div>
        <?php endif; ?>
      </div>
      <!--/centercol -->
      <?php get_sidebar(); ?>
      <div class="clr"></div>
    </div>
    <!--/columns -->
    <?php get_footer(); ?>
  10. i am lost - if this is the template that shows the front page of your site, then there should be at least the <ul> and <li> tags from the next/prev section of the code - and they are not.

    can you double check
    - that there is no cache or so;
    - that you are editing the right file;
    - that the file is saved to the server into the theme folder;
    - that there is not other tempalte that could do the front page.

    just for the future:

    How to use a pastebin

    Highlight and copy the code you wish to post in the pastebin
    Navigate to pastebin.com
    Place the browser's cursor in the pastebin's New Paste entry box.
    Paste the code you copied into that box.
    Scroll down and click the Submit button.
    Position the browser cursor in the browser's address (location) bar and copy the URL that appears in it. This is the URL for your pastebin code.
    Paste the URL into your WordPress forum post, so people who reply to your post can view your code.

  11. iselltheta
    Member
    Posted 3 years ago #

    The code I showed you was with the changes you had recommended. Here is how index.php looks originally and currently in my website. I have updated the file through editor each time as well. Thank You -

    <?php get_header(); ?>
    
    <div id="columns">
      <div id="centercol">
        <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
        <div class="box post" id="post-<?php the_ID(); ?>">
    <?php global $more; $more = 0; ?>
          <div class="content">
            <div class="post-title">
              <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                <?php the_title(); ?>
                </a></h2>
            </div>
            <!--/post-title -->
            <?php $postimageurl = get_post_meta($post->ID, 'post-img', true); if ($postimageurl) { ?>
            <div class="pic"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><img src="<?php echo $postimageurl; ?>" alt="<?php the_title_attribute(); ?>" /></a></div>
            <?php } ?>
            <!--/post-img -->
            <div class="social-links fl">
              <div style="padding:0 0 15px 0;"><span>
                <?php the_time('jS'); ?>
                </span></div>
              <div class="post-date">On
                <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?></p>
                <br />
                In
                <?php the_category(', ') ?>
                <br />
                by
                <?php the_author_posts_link(); ?>
                <div class="post-commets">
                  <?php _e('Comments'); ?>
                  <a href="<?php the_permalink(); ?>" title="View <?php _e('Comments'); ?>" class="font-sm">(
                  <?php comments_number(0, 1, '%'); ?>
                  )</a></div>
              </div>
              <!--/post-date -->
              <div class="clr"></div>
            </div>
            <!--/social-links -->
    <?php
    global $more;
    $more = 0;
    ?>
    
            <div class="content">
    
    <?php the_content(); ?>
              <!--/post-comments -->
              <p><span><?php _e('Leave Your'); ?> <a href="<?php the_permalink(); ?>" title="<?php _e('Leave Your'); ?> Response"><?php _e('Comments'); ?></a> &raquo;</span></p>
            </div>
            <!--/post-excerpt -->
            <div class="clr"></div>
          </div>
          <!--/content -->
        </div>
        <!--/box -->
        <?php endwhile; ?>
        <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
    
        <?php /*
            <ul>
    <li><?php next_posts_link('&laquo; Older Entries') ?></li>
    			<li><?php previous_posts_link('Newer Entries &raquo;') ?></li>
    		</ul>
    		*/ ?>
    
        <?php else : ?>
        <div class="box post">
          <div class="content">
            <div class="post-title">
              <h1>No Posts Were Found</h1>
            </div>
          </div>
        </div>
        <?php endif; ?>
      </div>
      <!--/centercol -->
      <?php get_sidebar(); ?>
      <div class="clr"></div>
    </div>
    <!--/columns -->
    <?php get_footer(); ?>
  12. have you tried to use the 'wp-pagenavi' plugin?
    the theme demo seems to be working with it.

    also, as this is a commercial theme, please ask at the theme vendor's site.

  13. iselltheta
    Member
    Posted 3 years ago #

    I'll check out that plugin. Thanks for your help. Enjoy your day!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.