ID; } endif; /** * Next Post ID * * @since Beauty Studio 1.0.0 * * @param int $post_id * @return int next_post id * */ if ( !function_exists('beauty_studio_get_next_post_id') ) : function beauty_studio_get_next_post_id( $post_id ) { /*Get a global post reference since get_adjacent_post() references it*/ global $post; /*Store the existing post object for later so we don't lose it*/ $oldGlobal = $post; /*Get the post object for the specified post and place it in the global variable*/ $post = get_post( $post_id ); /*Get the post object for the previous post*/ $next_post = get_next_post(); /*Reset our global object*/ $post = $oldGlobal; if ( '' == $next_post ) return 0; return $next_post->ID; } endif; /** * Navigation function * * @since Beauty Studio 1.0.0 * * @param int $post_id * @param string $type * @return int next_post id * */ if ( !function_exists('beauty_studio_single_navigation') ) : function beauty_studio_single_navigation( $post_id, $type = 'default' ){ $previous_post_id = beauty_studio_get_previous_post_id( $post_id ); $next_post_id = beauty_studio_get_next_post_id( $post_id ); if ( has_post_thumbnail( $previous_post_id ) ): $post_thumb_previous = wp_get_attachment_image_src(get_post_thumbnail_id( $previous_post_id ), 'post-thumbnail'); $post_thumb_previous = '
'; else: $post_thumb_previous = ''; endif; if ( has_post_thumbnail( $next_post_id ) ): $post_thumb_next = wp_get_attachment_image_src(get_post_thumbnail_id( $next_post_id ), 'post-thumbnail'); $post_thumb_next = '
'; else: $post_thumb_next = ''; endif; $navigation = ''; if( 'title-image' == $type ){ $previous = get_previous_post_link( '', $post_thumb_previous.esc_html( get_the_title( $previous_post_id ) ).'', true ); $next = get_next_post_link( '', $post_thumb_next.esc_html( get_the_title( $next_post_id ) ).'', true ); } else{ $previous = get_previous_post_link( '', $post_thumb_previous, true ); $next = get_next_post_link( '', $post_thumb_next, true ); } /*Only add markup if there's somewhere to navigate to.*/ if ( $previous || $next ) { $navigation = _navigation_markup( $previous . $next, 'post-navigation' ); } echo $navigation; } endif;