beans_post_navigation

Echo post navigation.

beans_post_navigation( )

Return: (void)

Source

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' );

}