Jump to content

Menu Display problem - help please


grafixGUY

Recommended Posts

Looking for some help with a little problem I have with an existing website. The website is

http://broadcasttools.com. The problem is with how the "Manuals" list is displaying (or not displaying, as is the case).

If you look here - http://broadcasttools.com/manuals/page/5/ you can see there are 54 manuals to be displayed, but only 50 are viewable. You can not navigate to the 6th page, even though it does exist (http://broadcasttools.com/manuals/page/6/)
 

Here is the .PHP code.  I'm sure it's something to do with the interval or rounding of of the integer value, but I can't sort it out.

<?php if($dis == ''){?>
<div class="row">
     <div class="col-md-12 navigation_cont">
     <?php
     $startpost=1;
      $startpost=10*($paged - 1)+1;
      $endpost = (10*$paged < $wp_query->found_posts ? 10*$paged : $wp_query->found_posts);
            ?>
      <div class="col-md-4">      
      <h5 class="displayResult">Showing results <?php echo $startpost; ?> - <?php echo $endpost; ?> of <?php echo $wp_query->found_posts; ?></h5>
      </div>
      <div class="col-md-7">
     <div class="navigation">
     <?php
     $cur_page = get_query_var('paged');
     $total_man = $wp_query->found_posts;
     $inetval = 10;
     $no_of_page  = round($total_man / $inetval);
     
     for($i = 1; $i <= $no_of_page; $i++ ){
         if($cur_page == $i ){ $cls ='active'; }else{$cls ='';}
     ?>
     
     <div class="nav_page <?php echo $cls; ?>"><a href="<?php echo site_url().'/manuals/page/'.$i; ?>"><?php echo $i; ?></a></div>
     <?php } ?>
      </div>
      </div>
    </div>
</div>
     <?php } else { ?>


<div class="row">
     <div class="col-md-12 navigation_cont">
     <?php
     $startpost=1;
      $startpost=10*($paged - 1)+1;
      $endpost = (10*$paged < $wp_query->found_posts ? 10*$paged : $wp_query->found_posts);
            ?>
      <div class="col-md-4">      
      <h5 class="displayResult">Showing results <?php echo $startpost; ?> - <?php echo $endpost; ?> of <?php echo $wp_query->found_posts; ?></h5>
      </div>
      <div class="col-md-7">
     <div class="navigation">
     <?php
     $cur_page = get_query_var('paged');
     $total_man = $wp_query->found_posts;
     $inetval = 10;
     $no_of_page  = round($total_man / $inetval);
     
     for($i = 1; $i <= $no_of_page; $i++ ){
         if($cur_page == $i ){ $cls ='active'; }else{$cls ='';}
     ?>
     
     <div class="nav_page <?php echo $cls; ?>"><a href="<?php echo site_url().'/manuals/page/'.$i.'/?pro=dis'; ?>"><?php echo $i; ?></a></div>
     <?php } ?>
      </div>
      </div>

    </div>
</div>
     <?php } ?>
      


 

Thank you.

Guy D. Corp

grafixCORP
 

 

Link to comment
Share on other sites

I don't know what $paged is set to, but what is this line for:

 $endpost = (10*$paged < $wp_query->found_posts ? 10*$paged : $wp_query->found_posts);

Why wouldn't the end post always be the number of found posts?  Why would it ever be less?

Link to comment
Share on other sites

That's fine, but I don't know what that value is supposed to represent, I don't know the meaning.  I don't know why the line of code is there to check if 10 * $paged is less than the number of found posts.  It sounds like that is a setting to limit the number of pages that are listed in the pagination, otherwise I don't see a reason to not always show the number of found posts.

Link to comment
Share on other sites

Hmmm...

I know that the page is limited to listing 10 results per page, then it adds pages as needed. The problem seems to be with the remainder and possibly only if that remainder is 4 or less, then it gets rounded down to 0 and doesn't generate a navigation page to display the results. The page is still generated, just the navigation to it is missing.

Not sure if that addresses your question or not.

Link to comment
Share on other sites

It returns total number of posts it has currently gone through to the current page, if it exceeds total posts show total posts value.
 

total posts 105

page 1 (start - end)
1 - 10,
page 2
11 - 20,
..so on
page 10
91 - 100

page 11 will be 10 x 11 this will exceed 105, so show total posts
101 - 105

 

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...