'post',
'post_parent' => false,
'id' => false,
'tag' => '',
'category' => '',
'offset' => 0,
'posts_per_page' => '4',
'order' => 'DESC',
'orderby' => 'date',
'include_date' => false,
'include_excerpt' => true,
'excerpt_l' => 16,
'taxonomy' => false,
'tax_term' => false,
'width' => 225,
'height' => 145,
'crop' => 1,
'tax_operator' => 'IN'
), $atts ) );
// Set up initial query for post
$args = array(
'post_type' => explode( ',', $post_type ),
'tag' => $tag,
'p' => $id,
'category_name' => $category,
'posts_per_page' => $posts_per_page,
'order' => $order,
'orderby' => $orderby,
'offset' => $offset
);
// If Post IDs
if( $id ) {
$posts_in = explode( ',', $id );
$args['post__in'] = $posts_in;
}
// If taxonomy attributes, create a taxonomy query
if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
// Term string to array
$tax_term = explode( ', ', $tax_term );
// Validate operator
if( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) )
$tax_operator = 'IN';
$tax_args = array(
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $tax_term,
'operator' => $tax_operator
)
)
);
$args = array_merge( $args, $tax_args );
}
// If post parent attribute, set up parent
if( $post_parent ) {
if( 'current' == $post_parent ) {
global $post;
$post_parent = $post->ID;
}
$args['post_parent'] = $post_parent;
}
$listing = new WP_Query( apply_filters( 'display_posts_shortcode_args', $args, $atts ) );
$count = 0;
if ( !$listing->have_posts() )
return apply_filters ('display_posts_shortcode_no_results', false );
$inner = '';
while ( $listing->have_posts() ): $listing->the_post(); global $post;
$count++;
if( $count == 1 ){
$style = ' news-main-post';
$word_count = $excerpt_l+6;
} else {
$style = ' news-list-posts';
$word_count = $excerpt_l;
}
$title = '
';
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
if ($count == 1 && has_post_thumbnail() ) $image = '';
else $image = '';
if ($include_date == 'true') $date = ''. get_the_date() . '
';
else $date = '';
if ($include_excerpt) $excerpt = '' .excerpt($word_count) . '';
else $excerpt = '';
if ($count == 1) $full_article = ' '. __( 'Full article', 'news' ) .'';
else $full_article = '';
$output = '' . $image . $title . $date . $excerpt . $full_article . '
';
$inner .= apply_filters( 'display_posts_shortcode_output', $output, $atts, $image, $title, $date, $excerpt, $full_article );
endwhile; wp_reset_query();
$open = apply_filters( 'display_posts_shortcode_wrapper_open', '' );
$close = apply_filters( 'display_posts_shortcode_wrapper_close', '
' );
$return = $open . $inner . $close;
return $return;
}
// STYLE 2 *********************************************************************************************************
add_shortcode('display_news_s2', 'be_display_posts_shortcode2');
function be_display_posts_shortcode2($atts) {
// Pull in shortcode attributes and set defaults
extract( shortcode_atts( array(
'post_type' => 'post',
'post_parent' => false,
'id' => false,
'tag' => '',
'category' => '',
'offset' => 0,
'posts_per_page' => '4',
'order' => 'DESC',
'orderby' => 'date',
'include_date' => false,
'include_excerpt' => true,
'excerpt_l' => 30,
'taxonomy' => false,
'tax_term' => false,
'width' => 225,
'height' => 145,
'crop' => 1,
'img_for_all' => false,
'tax_operator' => 'IN'
), $atts ) );
// Set up initial query for post
$args = array(
'post_type' => explode( ',', $post_type ),
'tag' => $tag,
'category_name' => $category,
'p' => $id,
'posts_per_page' => $posts_per_page,
'order' => $order,
'orderby' => $orderby,
'offset' => $offset
);
// If Post IDs
if( $id ) {
$posts_in = explode( ',', $id );
$args['post__in'] = $posts_in;
}
// If taxonomy attributes, create a taxonomy query
if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
// Term string to array
$tax_term = explode( ', ', $tax_term );
// Validate operator
if( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) )
$tax_operator = 'IN';
$tax_args = array(
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $tax_term,
'operator' => $tax_operator
)
)
);
$args = array_merge( $args, $tax_args );
}
// If post parent attribute, set up parent
if( $post_parent ) {
if( 'current' == $post_parent ) {
global $post;
$post_parent = $post->ID;
}
$args['post_parent'] = $post_parent;
}
$listing = new WP_Query( apply_filters( 'display_posts_shortcode_args', $args, $atts ) );
$count = 0;
if ( !$listing->have_posts() )
return apply_filters ('display_posts_shortcode_no_results', false );
$inner = '';
while ( $listing->have_posts() ): $listing->the_post(); global $post;
$count++;
if ($img_for_all == 'true') {
$fatured_img = has_post_thumbnail();
if( $count == 1 ){
$style = ' news-list-posts-all news-list-first-post';
} else {
$style = ' news-list-posts-all';
}
} else {
$fatured_img = $count == 1 && has_post_thumbnail();
if( $count == 1 ){
$style = ' news-main-post';
} else {
$style = ' news-list-posts';
}
}
$title = '';
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
if ($fatured_img) $image = '';
else $image = '';
if ($include_date == 'true') $date = ''. get_the_date() . '
';
else $date = '';
if ($include_excerpt) $excerpt = '' .excerpt($excerpt_l) . '';
else $excerpt = '';
if ($count == 1) $full_article = ' '. __( 'Full article', 'news' ) .'';
else $full_article = '';
$output = '' . $image . $title . $date . $excerpt . $full_article . '
';
$inner .= apply_filters( 'display_posts_shortcode_output', $output, $atts, $image, $title, $date, $excerpt, $full_article );
endwhile; wp_reset_query();
$open = apply_filters( 'display_posts_shortcode_wrapper_open', '' );
$close = apply_filters( 'display_posts_shortcode_wrapper_close', '
' );
$return = $open . $inner . $close;
return $return;
}
// LIST STYLE *********************************************************************************************************
add_shortcode('display_news_s3', 'be_display_posts_shortcode3');
function be_display_posts_shortcode3($atts) {
// Pull in shortcode attributes and set defaults
extract( shortcode_atts( array(
'post_type' => 'post',
'post_parent' => false,
'id' => false,
'tag' => '',
'category' => '',
'offset' => 0,
'posts_per_page' => '4',
'order' => 'DESC',
'orderby' => 'date',
'include_date' => false,
'include_excerpt' => false,
'excerpt_l' => 8,
'taxonomy' => false,
'tax_term' => false,
'tax_operator' => 'IN'
), $atts ) );
// Set up initial query for post
$args = array(
'post_type' => explode( ',', $post_type ),
'tag' => $tag,
'category_name' => $category,
'p' => $id,
'posts_per_page' => $posts_per_page,
'order' => $order,
'orderby' => $orderby,
'offset' => $offset
);
// If Post IDs
if( $id ) {
$posts_in = explode( ',', $id );
$args['post__in'] = $posts_in;
}
// If taxonomy attributes, create a taxonomy query
if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
// Term string to array
$tax_term = explode( ', ', $tax_term );
// Validate operator
if( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) )
$tax_operator = 'IN';
$tax_args = array(
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $tax_term,
'operator' => $tax_operator
)
)
);
$args = array_merge( $args, $tax_args );
}
// If post parent attribute, set up parent
if( $post_parent ) {
if( 'current' == $post_parent ) {
global $post;
$post_parent = $post->ID;
}
$args['post_parent'] = $post_parent;
}
$listing = new WP_Query( apply_filters( 'display_posts_shortcode_args', $args, $atts ) );
$count = 0;
if ( !$listing->have_posts() )
return apply_filters ('display_posts_shortcode_no_results', false );
$inner = '';
while ( $listing->have_posts() ): $listing->the_post(); global $post;
$count++;
if( $count == 1 ){
$style = ' news-main-post';
} else {
$style = ' news-list-posts';
}
$title = '';
if ($include_date == 'true') $date = ' '. get_the_date() . '
';
else $date = '';
if ($include_excerpt == 'true') $excerpt = '' .excerpt($excerpt_l) . '';
else $excerpt = '';
$output = ''. $title . $excerpt . $date . '
';
$inner .= apply_filters( 'display_posts_shortcode_output', $output, $atts, $title, $excerpt, $date );
endwhile; wp_reset_query();
$open = apply_filters( 'display_posts_shortcode_wrapper_open', '' );
$close = apply_filters( 'display_posts_shortcode_wrapper_close', '
' );
$return = $open . $inner . $close;
return $return;
}
// STYLE 4 *********************************************************************************************************
add_shortcode('display_news_s4', 'be_display_posts_shortcode4');
function be_display_posts_shortcode4($atts) {
// Pull in shortcode attributes and set defaults
extract( shortcode_atts( array(
'post_type' => 'post',
'post_parent' => false,
'id' => false,
'tag' => '',
'category' => '',
'offset' => 0,
'posts_per_page' => '4',
'order' => 'DESC',
'orderby' => 'date',
'include_date' => true,
'include_excerpt' => true,
'excerpt_l' => 17,
'taxonomy' => false,
'tax_term' => false,
'width' => 208,
'height' => 100,
'crop' => 1,
'tax_operator' => 'IN'
), $atts ) );
// Set up initial query for post
$args = array(
'post_type' => explode( ',', $post_type ),
'tag' => $tag,
'category_name' => $category,
'p' => $id,
'posts_per_page' => $posts_per_page,
'order' => $order,
'orderby' => $orderby,
'offset' => $offset
);
// If Post IDs
if( $id ) {
$posts_in = explode( ',', $id );
$args['post__in'] = $posts_in;
}
// If taxonomy attributes, create a taxonomy query
if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
// Term string to array
$tax_term = explode( ', ', $tax_term );
// Validate operator
if( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) )
$tax_operator = 'IN';
$tax_args = array(
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => $tax_term,
'operator' => $tax_operator
)
)
);
$args = array_merge( $args, $tax_args );
}
// If post parent attribute, set up parent
if( $post_parent ) {
if( 'current' == $post_parent ) {
global $post;
$post_parent = $post->ID;
}
$args['post_parent'] = $post_parent;
}
$listing = new WP_Query( apply_filters( 'display_posts_shortcode_args', $args, $atts ) );
$count = 0;
if ( !$listing->have_posts() )
return apply_filters ('display_posts_shortcode_no_results', false );
$inner = '';
while ( $listing->have_posts() ): $listing->the_post(); global $post;
$count++;
if( $count == 1 ){
$style = ' news-main-post';
$bullet = '';
$generate_title = '';
} else {
$style = ' news-list-posts';
$bullet = '•';
$generate_title = '';
}
if ($count == 1) $posted_in = ''. get_the_category_list( ', ' ) . ' »
';
else $posted_in = '';
$title = '';
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
if ($count == 1 && has_post_thumbnail() ) $image = '';
else $image = '';
if ($count == 1 && $include_date == 'true') $date = ' '. get_the_date() . '
';
else $date = '';
if ($count == 1 && $include_excerpt == 'true') $excerpt = '' .excerpt($excerpt_l) . '';
else $excerpt = '';
$output = ''. $posted_in . $image . $title . $excerpt . $date . '
';
$inner .= apply_filters( 'display_posts_shortcode_output', $output, $atts, $posted_in, $image, $title, $excerpt, $date );
endwhile; wp_reset_query();
$open = apply_filters( 'display_posts_shortcode_wrapper_open', '' );
$close = apply_filters( 'display_posts_shortcode_wrapper_close', '
' );
$return = $open . $inner . $close;
return $return;
}