CCCPaste

Exclude Terms Autoload Next Post

/* Exclude Terms Autoload Next Post */
function custom_jnews_autoload_post_wrap_attribute($attribute, $post_id) {
	$terms = array('10032', '8070', '1'); /* Terms ID */
	
	$attribute = " data-url=\"" . get_permalink($post_id) . "\" data-title=\"" . esc_attr(get_the_title($post_id)) . "\" data-id=\"" . esc_attr(get_the_ID()) . "\" ";

	$content = jnews_get_option('autoload_content', '');

	if($content === 'category') {
		$prev_post = get_previous_post(true, null, 'category');
	} else if($content === 'tag') {
		$prev_post = get_previous_post(true, null, 'post_tag');
	} else {
		$prev_post = get_previous_post(null, $terms);
	}

	if(!empty($prev_post)) {
		$attribute .= " data-prev=\"" . esc_url(get_permalink($prev_post->ID)) . "\" ";
	}

	return $attribute;
}
add_filter('jnews_post_wrap_attribute', 'custom_jnews_autoload_post_wrap_attribute', 99, 2);