Here is the code

<?php
// if show all is set
if( isset($_GET['showall']) ):
    $args = array( 'hide_empty' => 0 );
else:
// else show paged
    $page = ( get_query_var('paged') ) ? get_query_var( 'paged' ) : 1;
    // number of tags to show per-page
    $per_page = 5;
    $offset = ( $page-1 ) * $per_page;
    $args = array( 'number' => $per_page, 'offset' => $offset, 'hide_empty' => 0 );
endif;
$taxonomy = 'apptypes';
$appterms = get_terms( $taxonomy, $args );
foreach ($appterms as $appterm) {

$termID = $appterm->term_id;
$taxonomyName = $taxonomy;
$termchildren = get_term_children( $termID, $taxonomyName );
foreach ($termchildren as $child) {
    $termsub = get_term_by( 'id', $child, $taxonomyName );
    echo '<div style="margin:0 auto; width="100%"><h2>'. $appterm->name.'</h2></div>';
    echo $termsub->name;

     $wpq = array (
    'taxonomy' => $taxonomy,
    'term' => $termsub->slug
);
$query = new WP_Query ($wpq);
$article_count = $query->post_count;
echo '<table width="98%" border="0" cellspacing="0" cellpadding="5"  class="customtable">
  <tr class="customhead">
    <td align="left" valign="top">Year</td>
    <td align="left" valign="top">Kit Name</td>
    <td align="left" valign="top">Kit</td>
  </tr>
  <tr><td colspan="3">'.term_description($termsub->term_id,$taxonomyName) .'</td></tr>';    

if ($article_count) {
$posts = $query->posts;
foreach ($posts as $post) {
include(MY_THEME_FOLDER . '/appsloop.php');
}
}
echo ' </table>';








}}
echo '<table width="980" ><tr><td>';
// pagination
// if showall isn't set
if( !isset($_GET['showall']) ):
    $total_terms = wp_count_terms( 'apptypes' );
    $pages = ceil($total_terms/$per_page);
    // if there's more than one page
    if( $pages > 1 ):
        for ($pagecount=1; $pagecount <= $pages; $pagecount++):
            echo '<a href="'.get_permalink().'page/'.$pagecount.'/" style="padding:5px;">'.$pagecount.'</a> ';
        endfor;
        // link to show all
        echo '<a href="'.get_permalink().'?showall=true">show all</a>';
    endif;
else:
// showall is set, show link to get back to paged mode
    echo '<a href="'.get_permalink().'">show paged</a>';
endif;
echo '</td></tr></table>';
?> 

Can you guys help me how to paginate this?

Here is preview url

http://wpguru.in/themes/prothane/vehicle-applications/

regards

link|improve this question
feedback

closed as not a real question by hakre, Wyck, Brady, kaiser, Brady Mar 2 at 9:25

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. See the FAQ for guidance on how to improve it.

1 Answer

If you are uncomfortable coding your own pagination then I recommend that you use one of many many many pagination plug-ins that are available.

http://wordpress.org/extend/plugins/search.php?q=pagination

I personally use WP-PageNavi on nearly every WordPress site I build. I recommend it highly.

link|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.