• TakiraThemes

    (@takirathemes)


    Hi,

    I’m using the get_terms function to display the terms images, I can’t seem to work a way to display the pagination of them,

    Here is my code, the pagination appears but when I go to another page it just displays the same posts without offsetting them

    `<article class=”inner-content”>

    <?php the_field(text’, ‘option’); ?>
    <ul class=”list”>
    <?php
    $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1;
    $args = array(
    ‘taxonomy’ => ‘issues’,
    ‘term_args’ => array
    ( ‘hide_empty’ => true
    ),
    ‘paged’ => $paged
    );

    $terms = apply_filters( ‘taxonomy-images-get-terms’, ”, $args);

    foreach( (array) $terms as $term) {
    echo ‘

Viewing 1 replies (of 1 total)
  • Thread Starter TakiraThemes

    (@takirathemes)

    Got it to work, there seem to be a different problem now that the pagination is showing one more page then it should, it showing 2 pages but the second page has no posts,

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    			    $per_page    = 10;
    
    				$total_terms = count( get_terms( 'issues' ) );
    				$offset      = $per_page * ( $paged - 1) ;
    
    				$args = array(
    			        'taxonomy' => 'issues',
    					'term_args' => array
    					(		'hide_empty' => true,
    							'number' => $per_page,
    							'offset' => $offset
    			                ),
    			    );
    
    				$terms = apply_filters( 'taxonomy-images-get-terms', '', $args);
    
    				foreach( (array) $terms as $term) {
    					echo '<li>';
    					echo '<a href="' . esc_attr( get_term_link( $term ) ) . '" title="' . sprintf( __( "%s" ), $term->name ) . '" ' . '>' . wp_get_attachment_image( $term->image_id, 'issue' ) . '' . $term->name . '</a>';
    					echo '</li>';
    				}
    
    				?>
    </ul>
    
    			 <?php wp_pagenavi(); ?>
Viewing 1 replies (of 1 total)

The topic ‘Working with get_terms’ is closed to new replies.