/** * Display navigation to next/previous post when applicable. */ function post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous || is_singular('page')) { return; } $_previous_post_link = get_previous_post_link('<div class="nav-previous">%link</div>', _x('<span class="meta-nav">←</span> %title', 'Previous post link', 'the-one')); $_next_post_link = get_next_post_link('<div class="nav-next">%link</div>', _x('%title <span class="meta-nav">→</span>', 'Next post link', 'the-one')); ?> <nav class="navigation post-navigation" role="navigation"> <h4 class="screen-reader-text"><?php _e('Post navigation', 'the-one'); ?> </h4> <div class="nav-links"> <?php if (!empty($_previous_post_link) && !empty($_next_post_link)) { echo $_previous_post_link . $_next_post_link; } elseif (!empty($_previous_post_link)) { echo $_previous_post_link; } elseif (!empty($_next_post_link)) { echo '<div class="nav-previous"></div>' . $_next_post_link; } ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php }
public function test_get_previous_post_link_exclude_category() { $actual = get_previous_post_link('« %link', '%title', false, $this->cat_id); $title = get_post($this->post_ids[3])->post_title; $expected = '« <a href="' . home_url('?p=' . $this->post_ids[3]) . '" rel="prev">' . $title . '</a>'; $this->assertSame($expected, $actual); }
/** * Display navigation to next/previous post when applicable. */ function uncode_post_navigation($index_btn = '') { // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } $output = '<nav class="post-navigation" role="navigation"> <ul class="navigation">'; $prev = get_previous_post_link('<li class="page-prev"><span class="btn-container">%link</span></li>', '<i class="fa fa-angle-left"></i><span>' . esc_html__('Prev', 'uncode') . '</span>'); if ($prev !== '') { $output .= $prev; } else { $output .= '<li class="page-prev"><span class="btn-container"><span class="btn btn-link btn-icon-left btn-disable-hover"><i class="fa fa-angle-left"></i>' . esc_html__('Prev', 'uncode') . '</span></span></li>'; } if ($index_btn !== '') { $output .= '<li class="nav-back"><span class="btn-container">' . $index_btn . '</span></li>'; } $next = get_next_post_link('<li class="page-next"><span class="btn-container">%link</span></li>', '<span>' . esc_html__('Next', 'uncode') . '</span><i class="fa fa-angle-right"></i>'); if ($next !== '') { $output .= $next; } else { $output .= '<li class="page-next"><span class="btn-container"><span class="btn btn-link btn-icon-right btn-disable-hover">' . esc_html__('Next', 'uncode') . '<i class="fa fa-angle-right"></i></span></span></li>'; } $output .= '</ul><!-- .navigation --> </nav><!-- .post-navigation -->'; return $output; }
function hsinsider_the_posts_navigation() { if (!is_single()) { echo '<nav class="navigation post-navigation" role="navigation"><div class="nav-previous alignleft">' . get_next_posts_link('<i class="LATArrowLeft01"></i>Older Articles') . '</div><div class="nav-next alignright">' . get_previous_posts_link('Newer Articles<i class="LATArrowRight01"></i>') . '</div></nav>'; } else { echo '<nav class="navigation post-navigation" role="navigation"><div class="nav-previous alignleft">' . get_previous_post_link('%link', '<i class="LATArrowLeft01"></i>%title') . '</div><div class="nav-next alignright">' . get_next_post_link('%link', '%title<i class="LATArrowRight01"></i>') . '</div></nav>'; } }
function presscore_get_previous_post_link($link_text = '', $link_class = '', $dummy = '') { $post_link = get_previous_post_link('%link', $link_text); if ($post_link) { return str_replace('href=', 'class="' . esc_attr($link_class) . '" href=', $post_link); } return $dummy; }
function greybox_prev_post_link() { $gb_ppl = get_previous_post_link(); if (empty($gb_ppl)) { echo '<p>You are reading the oldest post.</p>'; } else { echo '<p>Read an older post:</p>'; previous_post_link(); } }
/** * Custom post navigation function */ function flatbook_post_navigation() { $nav = ''; $prev = get_previous_post_link('<div class="pull-left">%link</div>', '← %title', true); $next = get_next_post_link('<div class="pull-right">%link</div>', '%title →', true); if ($prev || $next) { $nav = _navigation_markup($prev . $next, 'post-navigation'); } echo $nav; }
function sensitive_skin_bootstrap_posts_navigation($args = array()) { $args = wp_parse_args($args, array('prev_text' => '%title', 'next_text' => '%title', 'screen_reader_text' => __('Post navigation'))); $navigation = ''; $previous = get_previous_post_link('<div class="nav-previous">%link</div>', $args['prev_text']); $next = get_next_post_link('<div class="nav-next">%link</div>', $args['next_text']); // Only add markup if there's somewhere to navigate to. if ($previous || $next) { $navigation = _navigation_markup($previous . $next, 'post-navigation', $args['screen_reader_text']); } return $navigation; }
function piedtheme_post_navigation($args = array()) { $args = wp_parse_args($args, array('prev_text' => '%title', 'next_text' => '%title', 'screen_reader_text' => __('Post navigation'))); $navigation = ''; $previousArrow = get_previous_post_link('<div class="arrow-previous">%link</div>', '<i class="fa fa-backward nav"></i>'); $previous = get_previous_post_link('<div class="navtext">%link</div>', '<p>' . $args['prev_text'] . '</p>'); $nextArrow = get_next_post_link('<div class="arrow-next">%link</div>', '<i class="fa fa-forward nav"></i>'); $next = get_next_post_link('<div class="navtext">%link</div>', '<p>' . $args['next_text'] . '</p>'); // Only add markup if there's somewhere to navigate to. /* if ( $previous || $next ) { $navigation = _navigation_markup( $previous . $next, 'post-navigation', $args['screen_reader_text'] ); }*/ $navigation = "<nav class='navigation post-navigation' role='navigation'>\n\t\t<h2 class='screen-reader-text'>Posts navigation</h2>\n\t\t<div class='nav-links clear'>\n\t\t<div class='nav-previous'>" . $previousArrow . $previous . "</div><div class='nav-next'>" . $nextArrow . $next . "</div></div>\n\t</nav>"; echo $navigation; }
public static function get_the_post_navigation($args = array()) { $args = wp_parse_args($args, array('prev_text' => '%title', 'next_text' => '%title', 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'category', 'screen_reader_text' => __('Post navigation', 'wp-starter-theme'), 'aligned' => false)); $navigation = ''; $prev_template = $next_template = '<li>%link</li>'; if ($args['aligned']) { $prev_template = str_replace('<li>', '<li class="pager-prev">', $prev_template); $next_template = str_replace('<li>', '<li class="pager-next">', $next_template); } $prev_link = get_previous_post_link($prev_template, $args['prev_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy']); $next_link = get_next_post_link($next_template, $args['next_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy']); if ($prev_link || $next_link) { $navigation = '<ul class="pager">' . $prev_link . $next_link . '</ul>'; $navigation = _navigation_markup($navigation, 'post-navigation', $args['screen_reader_text']); } return $navigation; }
/** * Next/previous post buttons helper. * * Works only in the loop. Sample options array: * array( * 'wrap' => '<div class="paginator-r inner-navig">%LINKS%</div>', * 'title_wrap' => '<span class="pagin-info">%TITLE%</span>', * 'no_link_next' => '<a href="#" class="prev no-act" onclick="return false;"></a>', * 'no_link_prev' => '<a href="#" class="next no-act" onclick="return false;"></a>', * 'title' => 'Post %CURRENT% of %MAX%', * 'next_post_class' => 'prev', * 'prev_post_class' => 'next', * next_post_text' => '', * 'prev_post_text' => '', * 'echo' => true * ) * * @param array $args Options array. * @since presscore 1.0 */ function presscore_post_navigation($args = array()) { global $wpdb, $post; if (!in_the_loop()) { return false; } $next_post_text = _x('Prev', 'post nav', LANGUAGE_ZONE); $prev_post_text = _x('Next', 'post nav', LANGUAGE_ZONE); $defaults = array('wrap' => '<div class="navigation-inner">%LINKS%</div>', 'title_wrap' => '', 'no_link_next' => '<a class="prev-post disabled" href="javascript: void(0);">' . $next_post_text . '</a>', 'no_link_prev' => '<a class="next-post disabled" href="javascript: void(0);">' . $prev_post_text . '</a>', 'title' => '', 'next_post_class' => 'prev-post', 'prev_post_class' => 'next-post', 'next_post_text' => $next_post_text, 'prev_post_text' => $prev_post_text, 'echo' => true); $args = apply_filters('presscore_post_navigation-args', wp_parse_args($args, $defaults)); $args = wp_parse_args($args, $defaults); $title = $args['title']; if (false !== strpos($title, '%CURRENT%') || false !== strpos($title, '%MAX%')) { $posts = new WP_Query(array('no_found_rows' => true, 'fields' => 'ids', 'posts_per_page' => -1, 'post_type' => get_post_type(), 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC')); $current = 1; foreach ($posts->posts as $index => $post_id) { if ($post_id == get_the_ID()) { $current = $index + 1; break; } } $title = str_replace(array('%CURRENT%', '%MAX%'), array($current, count($posts->posts)), $title); } $output = ''; $output .= str_replace(array('%TITLE%'), array($title), $args['title_wrap']); // next link $next_post_link = get_next_post_link('%link', $args['next_post_text']); if ($next_post_link) { $next_post_link = str_replace('href=', 'class="' . $args['next_post_class'] . '" href=', $next_post_link); } else { $next_post_link = $args['no_link_next']; } // previos link $previous_post_link = get_previous_post_link('%link', $args['prev_post_text']); if ($previous_post_link) { $previous_post_link = str_replace('href=', 'class="' . $args['prev_post_class'] . '" href=', $previous_post_link); } else { $previous_post_link = $args['no_link_prev']; } $output = str_replace(array('%LINKS%', '%NEXT_POST_LINK%', '%PREV_POST_LINK%'), array($next_post_link . $previous_post_link, $next_post_link, $previous_post_link), $args['wrap']); if ($args['echo']) { echo $output; } return $output; }
?> </div> <div class="row content content-single"> <div class="col xs-12 md-10 offset-md-1 lg-8 offset-lg-2"> <?php the_field('description'); ?> <div class="row project-links"> <ul class="clearfix <?php echo get_previous_post_link('%link') ? "" : "left"; echo get_next_post_link('%link') ? "" : "right"; ?> "> <?php echo get_previous_post_link('%link') ? '<li class="prev">' . get_previous_post_link("%link") . '</li>' : ""; ?> <!-- <li class="pipe">|</li> --> <?php echo get_next_post_link('%link') ? '<li class="next">' . get_next_post_link("%link") . '</li>' : ""; ?> </ul> </div> </div> </div> </div> </div> <script> var imageHeight = <?php
echo get_the_title(); ?> </h1> </div> <div id="article-content"> <?php if (have_posts()) { while (have_posts()) { the_post(); the_content(); $prev = get_adjacent_post(false, '', false); $next = get_adjacent_post(false, '', true); if (empty($next)) { $nextlink = ''; } else { $nextlink = get_previous_post_link('%link', '<li class="rs-right"></li>'); } if (empty($prev)) { $prevlink = ''; } else { $prevlink = get_next_post_link('%link', '<li class="rs-left"></li>'); } } } ?> </div> <?php $posts = get_field('related_latest_posts'); if ($posts) { ?> <div id="mightlike">
<header class="header-title clearfix"> <?php if (wpo_theme_options('post-title')) { ?> <h2 class="entry-title pull-left"> <?php the_title(); ?> </h2> <?php } ?> <div class="pull-right"> <?php if (get_previous_post_link() != '') { ?> <div class="btn btn-link"> <?php previous_post_link('%link', ' <i class="fa fa-angle-left"></i> Previous'); ?> </div> <?php } ?> <?php if (get_next_post_link() != '') { ?> <div class="btn btn-link"> <?php next_post_link('%link', 'Next <i class="fa fa-angle-right"></i> ');
function sunset_post_navigation() { $nav = '<div class="row">'; $prev = get_previous_post_link('<div class="post-link-nav"><span class="sunset-icon sunset-chevron-left" aria-hidden="true"></span> %link</div>', '%title'); $nav .= '<div class="col-xs-12 col-sm-6">' . $prev . '</div>'; $next = get_next_post_link('<div class="post-link-nav">%link <span class="sunset-icon sunset-chevron-right" aria-hidden="true"></span></div>', '%title'); $nav .= '<div class="col-xs-12 col-sm-6 text-right">' . $next . '</div>'; $nav .= '</div>'; return $nav; }
/** * Echo post navigation. * * @since 1.0.0 */ function beans_post_navigation() { /** * Filter whether {@see beans_post_navigation()} should be short-circuit or not. * * @since 1.0.0 * * @param bool $pre True to short-circuit, False to let the function run. */ if (apply_filters('beans_pre_post_navigation', !is_singular('post'))) { return; } $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } beans_open_markup_e('beans_post_navigation', 'ul', array('class' => 'uk-pagination', 'role' => 'navigation')); if ($previous) { // Previous. beans_open_markup_e('beans_post_navigation_item[_previous]', 'li', array('class' => 'uk-pagination-previous')); echo get_previous_post_link('%link', __('Previous', 'tm-beans')); beans_close_markup_e('beans_post_navigation_item[_previous]', 'li'); } if ($next) { // Next. beans_open_markup_e('beans_post_navigation_item[_next]', 'li', array('class' => 'uk-pagination-next')); echo get_next_post_link('%link', __('Next', 'tm-beans')); beans_close_markup_e('beans_post_navigation_item[_next]', 'li'); } beans_close_markup_e('beans_post_navigation', 'ul'); }
wp_link_pages(array('next_or_number' => 'number', 'nextpagelink' => __('Next page', 'cuvey'), 'previouspagelink' => __('Previous page', 'cuvey'), 'pagelink' => '%', 'link_before' => '<span class="ft-btn">', 'link_after' => '</span>', 'before' => '<div class="clearfix"></div>' . __('Pages:', 'cuvey') . ' <div class="ft-article-pages">', 'after' => '</div>')); ?> </div><!-- end blog --> <div class="clearfix"></div> <hr> <?php } ?> <?php if (get_next_post_link('« %link', '%title', 1) or get_previous_post_link('%link »', '%title', 1)) { ?> <div class="prev-next-btn" style="display:none;"> <ul class="pager"> <li class="previous"> <?php previous_posts_link('%link', '<span class="meta-nav">' . _x('←', 'Previous feature', 'cuvey') . '</span> %title'); ?> </li> <li class="next"> <?php next_posts_link('%link', '%title <span class="meta-nav">' . _x('→', 'Next feature', 'cuvey') . '</span>'); ?> </li> </ul> </div>
/** * Return navigation to next/previous post when applicable. * * @since 4.1.0 * @since 4.4.0 Introduced the `in_same_term`, `excluded_terms`, and `taxonomy` arguments. * * @param array $args { * Optional. Default post navigation arguments. Default empty array. * * @type string $prev_text Anchor text to display in the previous post link. Default '%title'. * @type string $next_text Anchor text to display in the next post link. Default '%title'. * @type bool $in_same_term Whether link should be in a same taxonomy term. Default false. * @type array|string $excluded_terms Array or comma-separated list of excluded term IDs. Default empty. * @type string $taxonomy Taxonomy, if `$in_same_term` is true. Default 'category'. * @type string $screen_reader_text Screen reader text for nav element. Default 'Post navigation'. * } * @return string Markup for post links. */ function get_the_post_navigation($args = array()) { $args = wp_parse_args($args, array('prev_text' => '%title', 'next_text' => '%title', 'in_same_term' => false, 'excluded_terms' => '', 'taxonomy' => 'category', 'screen_reader_text' => __('Post navigation'))); $navigation = ''; $previous = get_previous_post_link('<div class="nav-previous">%link</div>', $args['prev_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy']); $next = get_next_post_link('<div class="nav-next">%link</div>', $args['next_text'], $args['in_same_term'], $args['excluded_terms'], $args['taxonomy']); // Only add markup if there's somewhere to navigate to. if ($previous || $next) { $navigation = _navigation_markup($previous . $next, 'post-navigation', $args['screen_reader_text']); } return $navigation; }
<div class="comments"> <?php //comments_template(); ?> </div> <?php } ?> <?php if (!is_home()) { ?> <!-- Footer navigation --> <div id="nav-footer"> <?php if (!($link = get_previous_post_link())) { ?> <?php } else { ?> <div class="post-nav-left button normal clearfix"> <?php previous_post_link('%link', 'Next'); ?> </div> <?php } ?> <?php if (!($link = get_next_post_link())) { ?>
<?php /** * @package Make */ // Left arrow $previous_link = get_next_post_link('<div class="nav-previous">%link</div>', '%title'); // Right arrow $next_link = get_previous_post_link('<div class="nav-next">%link</div>', '%title'); if ('' !== $next_link || '' !== $previous_link) { ?> <nav class="navigation post-navigation" role="navigation"> <span class="screen-reader-text"><?php esc_html_e('Post navigation', 'make'); ?> </span> <div class="nav-links"> <?php echo $previous_link; echo $next_link; ?> </div> </nav> <?php }
the_content(); ?> <div class="page_navigation"> <?php if (get_next_post_link('%link', '%title', true)) { ?> <?php next_post_link('<div class="next_post_button">%link</div>', __('← to next post', 'sensationred'), true); ?> <div class="next_blog_link"><?php next_post_link('%link', '%title', true); ?> </div> <?php } if (get_previous_post_link('%link', '%title', true)) { ?> <?php previous_post_link('<div class="previous_post_button">%link</div>', __('to previous post →', 'sensationred'), TRUE); ?> <div class="previous_blog_link"><?php previous_post_link('%link', '%title', TRUE); ?> </div> <?php } ?> </div> <!-- page nav --> <?php }
function shortcode_callback($atts, $content = null, $function_name) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $in_same_term = $this->shortcode_atts['in_same_term']; $taxonomy_name = $this->shortcode_atts['taxonomy_name']; $hide_prev = $this->shortcode_atts['hide_prev']; $hide_next = $this->shortcode_atts['hide_next']; $prev_text = $this->shortcode_atts['prev_text']; $next_text = $this->shortcode_atts['next_text']; // do not output anything if both prev and next links are disabled if ('on' === $hide_prev && 'on' === $hide_next) { return; } $module_class = ET_Builder_Element::add_module_order_class($module_class, $function_name); $previous_link_text = '' !== $prev_text ? esc_html($prev_text) : '%title'; $next_link_text = '' !== $next_text ? esc_html($next_text) : '%title'; $in_same_term = 'on' === $in_same_term && !is_page() ? true : false; if ('' === $taxonomy_name) { $current_taxonomy = is_singular('project') ? 'project_category' : 'category'; } else { $current_taxonomy = sanitize_text_field($taxonomy_name); } ob_start(); $previous_post_link = get_previous_post_link('%link', '<span class="meta-nav">' . esc_html(_x('←', 'Previous post link', 'et_builder')) . '</span> ' . $previous_link_text, $in_same_term, '', $current_taxonomy); $next_post_link = get_next_post_link('%link', $next_link_text . ' <span class="meta-nav">' . esc_html(_x('→', 'Next post link', 'et_builder')) . '</span>', $in_same_term, '', $current_taxonomy); if ('on' !== $hide_prev && '' !== $previous_post_link) { ?> <span class="nav-previous"> <?php echo $previous_post_link; ?> </span> <?php } if ('on' !== $hide_next && '' !== $next_post_link) { ?> <span class="nav-next"> <?php echo $next_post_link; ?> </span> <?php } $page_links = ob_get_contents(); ob_end_clean(); $output = sprintf('<div class="et_pb_posts_nav et_pb_module nav-single%2$s"%1$s> %3$s </div>', '' !== $module_id ? sprintf(' id="%1$s"', esc_attr($module_id)) : '', '' !== $module_class ? sprintf(' %1$s', esc_attr(ltrim($module_class))) : '', $page_links); return $output; }
function camp_post_navigation() { if (get_previous_posts_link()) { echo '<div class = "camp-prev-post-link" >'; previous_posts_link(__('Newer posts →', 'camp')); echo '</div>'; } if (get_next_posts_link()) { echo '<div class = "camp-next-post-link" >'; next_posts_link(__('← Older posts', 'camp')); echo '</div>'; } if (is_single()) { if (get_previous_post_link()) { echo '<div class = "camp-prev-post-link" >'; previous_post_link('%link', __('Next post →', 'camp')); echo '</div>'; } if (get_next_post_link()) { echo '<div class = "camp-next-post-link" >'; next_post_link('%link', __('← Previous post', 'camp')); echo '</div>'; } } }
function wm_post_nav() { //Requirements check if (!is_singular() || is_page()) { return; } //Helper variables $output = $prev_class = $next_class = ''; $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); //Requirements check if (!$next && !$previous || is_attachment() && 'attachment' == $previous->post_type) { return; } //Preparing output if ($previous && has_post_thumbnail($previous->ID)) { $prev_class = " has-post-thumbnail"; } if ($next && has_post_thumbnail($next->ID)) { $next_class = " has-post-thumbnail"; } if (is_attachment()) { $output .= get_previous_post_link('<div class="nav-previous' . $prev_class . '">%link</div>', __('<span class="meta-nav">Published In</span> <span class="post-title">%title</span>', 'wm_domain')); } else { $output .= get_previous_post_link('<div class="nav-previous' . $prev_class . '">%link</div>', __('<span class="meta-nav">Previous</span> <span class="post-title">%title</span>', 'wm_domain')); $output .= get_next_post_link('<div class="nav-next' . $next_class . '">%link</div>', __('<span class="meta-nav">Next</span> <span class="post-title">%title</span>', 'wm_domain')); } if ($output) { $output = '<nav class="navigation post-navigation" role="navigation"><h1 class="screen-reader-text">' . __('Post navigation', 'wm_domain') . '</h1><div class="nav-links">' . $output . '</div></nav>'; } //Output echo apply_filters('wmhook_wm_post_nav_output', $output); }
/** * Display previous post link that is adjacent to the current post. * * @since 1.5.0 * @see get_previous_post_link() * * @param string $format Optional. Link anchor format. * @param string $link Optional. Link permalink format. * @param bool $in_same_term Optional. Whether link should be in a same taxonomy term. * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. * @param string $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'. */ function previous_post_link($format = '« %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category') { echo get_previous_post_link($format, $link, $in_same_cat, $excluded_terms, $taxonomy); }
function barcelona_page_nav($query = FALSE) { if (!$query) { global $wp_query; $query = $wp_query; } $barcelona_output = ''; $barcelona_post_type = get_post_type(); if (is_home() || is_archive() || is_search()) { if ($query->max_num_pages > 1) { $barcelona_output = paginate_links(array('base' => str_replace(99999, '%#%', esc_url(get_pagenum_link(99999))), 'format' => '', 'current' => max(1, get_query_var('paged')), 'total' => $query->max_num_pages, 'prev_text' => esc_html__('« Prev', 'barcelona'), 'next_text' => esc_html__('Next »', 'barcelona'))); $barcelona_output = '<div class="pagination">' . $barcelona_output . '</div>'; } } else { if (is_single() && $barcelona_post_type == 'post' && barcelona_get_option('show_post_nav') == 'on') { $barcelona_prev = get_previous_post_link('%link', '<span class="fa fa-angle-left"></span> %title'); $barcelona_next = get_next_post_link('%link', '<span class="fa fa-angle-right"></span> %title'); if (!is_null($barcelona_prev) || !is_null($barcelona_next)) { ?> <div class="row posts-nav"> <div class="col col-xs-6"> <?php echo $barcelona_prev; ?> </div> <div class="col col-xs-6"> <?php echo $barcelona_next; ?> </div> </div><!-- .posts-nav --> <?php } } } echo $barcelona_output; }
function dh_post_nav() { global $post; // Don't print empty markup if there's nowhere to navigate. $previous = is_attachment() ? get_post($post->post_parent) : get_adjacent_post(false, '', true); $next = get_adjacent_post(false, '', false); if (!$next && !$previous) { return; } ?> <nav class="post-navigation" role="navigation"> <div class="row"> <?php $prev_link = get_previous_post_link('%link', _x('%title', 'Previous post link', DH_DOMAIN)); ?> <div class="col-sm-6"> <?php if ($prev_link) { ?> <div class="prev-post"> <span> <?php echo __('Previous article', DH_DOMAIN); ?> </span> <?php echo dhecho($prev_link); ?> </div> <?php } ?> </div> <?php $next_link = get_next_post_link('%link', _x('%title', 'Next post link', DH_DOMAIN)); ?> <div class="col-sm-6"> <?php if (!empty($next_link)) { ?> <div class="next-post"> <span> <?php echo __('Next article', DH_DOMAIN); ?> </span> <?php echo dhecho($next_link); ?> </div> <?php } ?> </div> </div> </nav> <?php }
function thachpham_pagination() { /* * Không hiển thị phân trang nếu trang đó có ít hơn 2 trang */ if ($GLOBALS['wp_query']->max_num_pages < 2) { return ''; } ?> <nav class="pagination" role="navigation"> <?php if (get_next_post_link()) { ?> <div class="prev"><?php next_posts_link(__('Older Posts', 'thachpham')); ?> </div> <?php } ?> <?php if (get_previous_post_link()) { ?> <div class="next"><?php previous_posts_link(__('Newer Posts', 'thachpham')); ?> </div> <?php } ?> </nav><?php }
<?php while (have_posts()) { the_post(); ?> <?php get_template_part('content', 'single'); ?> <?php } ?> <?php if (get_previous_post_link() || get_next_post_link()) { ?> <ul class="pager"> <?php if (get_previous_post_link()) { ?> <li class="previous"><?php previous_post_link('%link', __('← Previous', 'photos')); ?> </li> <?php } ?> <?php if (get_next_post_link()) { ?> <li class="next"><?php next_post_link('%link', __('Next →', 'photos')); ?> </li>
function get_json($_post) { foreach ($_post as $post) { $_post['post_class'] = implode(' ', get_post_class('', $_post['ID'])); // Get next and previous links global $post; $post = get_post($_post['ID']); ob_start(); echo get_next_post_link(); $next_post_link = ob_get_contents(); ob_end_clean(); $next_post_link = str_replace('rel="next">', 'rel="next"><span class="screen-reader-text">', $next_post_link); $next_post_link = str_replace('</a> »', '</span></a>', $next_post_link); ob_start(); echo get_previous_post_link(); $previous_post_link = ob_get_contents(); ob_end_clean(); $previous_post_link = str_replace('rel="prev">', 'rel="prev"><span class="screen-reader-text">', $previous_post_link); $previous_post_link = str_replace('</a>', '</span></a>', $previous_post_link); $previous_post_link = str_replace('« ', '', $previous_post_link); $_post['next_post'] = $next_post_link; $_post['previous_post'] = $previous_post_link; } return $_post; }