post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); $css = ''; if ( is_attachment() && 'attachment' == $previous->post_type ) { return; } if ( $previous && has_post_thumbnail( $previous->ID ) ) { $prevThumb = wp_get_attachment_image_src( get_post_thumbnail_id( $previous->ID ), 'bookmark-navigation' ); $css .= ' .post-navigation .nav-previous { background-image: url(' . esc_url( $prevThumb[0] ) . '); } '; } if ( $next && has_post_thumbnail( $next->ID ) ) { $nextThumb = wp_get_attachment_image_src( get_post_thumbnail_id( $next->ID ), 'bookmark-navigation' ); $css .= ' .post-navigation .nav-next { background-image: url(' . esc_url( $nextThumb[0] ) . '); } '; } wp_add_inline_style( 'bookmark-style', $css ); } add_action( 'wp_enqueue_scripts', 'bookmark_post_nav_background' );