Example #1
0
                    previous_post_link($previousText, $previousPostTitle);
                } else {
                    previous_post_link($previousText);
                }
                echo $navPreviousClose;
            }
            if ($alwaysShowLinks || thb_post_has_next()) {
                echo $navNextOpen;
                if ($nextPostTitle != '') {
                    next_post_link($nextText, $nextPostTitle);
                } else {
                    next_post_link($nextText);
                }
                echo $navNextClose;
            }
        } else {
            if (thb_page_has_previous()) {
                echo $navPreviousOpen;
                previous_posts_link($previousText);
                echo $navPreviousClose;
            }
            if (thb_page_has_next()) {
                echo $navNextOpen;
                next_posts_link($nextText);
                echo $navNextClose;
            }
        }
        break;
}
?>
</nav>
 function thb_pagination($config = array())
 {
     $show_pagination = true;
     $base_config = array('type' => 'numbers', 'class' => '', 'id' => '', 'previousText' => is_single() ? '%link' : __('Previous', 'thb_text_domain'), 'nextText' => is_single() ? '%link' : __('Next', 'thb_text_domain'), 'previousPostTitle' => '', 'nextPostTitle' => '', 'arrowPreviousText' => '', 'arrowNextText' => '', 'alwaysShowLinks' => false);
     $base_config = thb_array_asum($base_config, $config);
     $base_config['previousText'] = $base_config['arrowPreviousText'] . $base_config['previousText'];
     $base_config['nextText'] = $base_config['nextText'] . $base_config['arrowNextText'];
     if ($base_config['type'] == 'numbers') {
         global $wp_query;
         $show_pagination = $wp_query->max_num_pages > 1;
     } else {
         if (is_single()) {
             $show_pagination = thb_post_has_previous() || thb_post_has_next();
         } else {
             $show_pagination = thb_page_has_previous() || thb_page_has_next();
         }
     }
     if (!$show_pagination) {
         return;
     }
     $pagination_template = new THB_TemplateLoader('frontend/components/pagination', $base_config);
     $pagination_template->render();
 }