News & Blog Designer Pack Shortcodes

Below, you’ll find a detailed guide on how to add the News & Blog Designer Pack Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the News & Blog Designer Pack Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the News & Blog Designer Pack Plugin and the shortcodes it provides:

Plugin Icon
News & Blog Designer Pack – WordPress Blog Plugin — (Blog Post Grid, Blog Post Slider, Blog Post Carousel, Blog Post Ticker, Blog Post Masonry)

"News & Blog Designer Pack is a versatile WordPress Blog Plugin. It features Blog Post Grid, Slider, Carousel, Ticker, and Masonry functions to enhance your site's blog aesthetics."

★★★★☆ (58) Active Installs: 30000+ Tested with: 6.3.2 PHP Version: 5.4
Included Shortcodes:
  • [bdp_post_gridbox]
  • [bdp_post_list]
  • [bdp_masonry]
  • [bdp_ticker]
  • [bdp_post]
  • [bdp_post_carousel]
  • [bdp_post_slider]

News & Blog Designer Pack [bdp_post_gridbox] Shortcode

The Blog Designer Pack shortcode, ‘bdp_post_gridbox’, renders a grid box layout of blog posts. It’s highly customizable, allowing you to set a limit on posts, specify categories, and choose the design. It also lets you toggle the visibility of the author, date, category, content, and more. You can set the content word limit and order posts by date or other parameters. Shortcode: [bdp_post_gridbox]

Shortcode: [bdp_post_gridbox]

Parameters

Here is a list of all possible bdp_post_gridbox shortcode parameters and attributes:

  • limit – sets the maximum number of posts to display
  • category – selects posts from specific categories
  • design – chooses the design layout for the posts
  • show_author – decides whether to display the author’s name
  • pagination – toggles the pagination feature on or off
  • show_date – decides whether to show the date of the post
  • show_category – decides whether to display the category of the post
  • show_content – decides whether to display the content of the post
  • content_words_limit – sets the maximum number of words in the post content
  • show_read_more – decides whether to display the ‘read more’ link
  • order – sets the order of the posts, either ascending or descending
  • orderby – sets the parameter to sort the posts by
  • show_tags – decides whether to display the tags of the post
  • show_comments – decides whether to display the number of comments

Examples and Usage

Basic example – A shortcode that displays a grid box of posts, with default parameters.

[bdp_post_gridbox]

Advanced examples

Display a grid box of posts from a specific category, with a limit of 10 posts, in ascending order, and without pagination.

[bdp_post_gridbox limit='10' category='news' order='ASC' pagination='false']

Show a grid box of posts with a specific design, without showing the author, date, category, tags, and comments, and with a content word limit of 20.

[bdp_post_gridbox design='design-2' show_author='false' show_date='false' show_category='false' show_tags='false' show_comments='false' content_words_limit='20']

Display a grid box of posts, ordered by title, with a ‘read more’ button, and without showing the post content.

[bdp_post_gridbox orderby='title' show_read_more='true' show_content='false']

PHP Function Code

In case you have difficulties debugging what causing issues with [bdp_post_gridbox] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bdp_post_gridbox', 'bdp_get_posts_gridbox' );

Shortcode PHP function:

function bdp_get_posts_gridbox( $atts, $content = null ) {
    
	// Taking some globals
	global $post, $multipage;
	
    // Shortcode Parameters
	extract(shortcode_atts(array(
		'limit' 				=> 20,
		'category' 				=> '',
		'design' 				=> 'design-1',
		'show_author' 			=> 'true',
		'pagination' 			=> 'true',
		'show_date' 			=> 'true',
		'show_category' 		=> 'true',
		'show_content' 			=> 'true',
		'content_words_limit' 	=> 10,
		'show_read_more' 		=> 'true',
		'order'					=> 'DESC',
		'orderby'				=> 'date',
		'show_tags'				=> 'true',
		'show_comments'			=> 'true',
		), $atts, 'bdp_post_gridbox'));

	$shortcode_designs 	= bdp_recent_post_gridbox_designs();
	$posts_per_page 	= !empty($limit) 					? $limit 						: 20;
	$cat 				= (!empty($category))				? explode(',',$category) 		: '';	
	$design 			= ($design && (array_key_exists(trim($design), $shortcode_designs))) ? trim($design) 	: 'design-1';
	$showAuthor 		= ($show_author == 'false')			? 'false'						: 'true';
	$pagination 		= ($pagination == 'false')			? 'false'						: 'true';
	$showDate 			= ( $show_date == 'false' ) 		? 'false'						: 'true';
	$showCategory 		= ( $show_category == 'false' )		? 'false' 						: 'true';
	$showContent 		= ( $show_content == 'false' ) 		? 'false' 						: 'true';
	$words_limit 		= !empty( $content_words_limit ) 	? $content_words_limit 			: 20;
	$showreadmore 		= ( $show_read_more == 'false' )	? 'false' 						: 'true';
	$order 				= ( strtolower($order) == 'asc' ) 	? 'ASC' 						: 'DESC';
	$orderby 			= !empty($orderby)					? $orderby 						: 'date';
	$show_tags 			= ( $show_tags == 'false' ) 		? 'false'						: 'true';
	$show_comments 		= ( $show_comments == 'false' ) 	? 'false'						: 'true';
	$multi_page			= ( $multipage || is_single() ) 	? 1 							: 0;

	// Shortcode file
	$post_design_file_path 	= BDP_DIR . '/templates/grid-box/' . $design . '.php';
	$design_file 			= (file_exists($post_design_file_path)) ? $post_design_file_path : '';

	// Taking some variables
	$bdpcount = 0;

	// Pagination parameter
	if( $multi_page ) {
		$paged = isset( $_GET['bdpp-page'] ) ? $_GET['bdpp-page'] : 1;
	} elseif ( get_query_var( 'paged' ) ) {
		$paged = get_query_var('paged');
	} elseif ( get_query_var( 'page' ) ) {
		$paged = get_query_var( 'page' );
	} else {
		$paged = 1;
	}

	// WP Query Parameters
	$args = array ( 
		'post_type'      		=> BDP_POST_TYPE,
		'post_status' 			=> array('publish'),
		'order'          		=> $order,
		'orderby'        		=> $orderby, 
		'posts_per_page' 		=> $posts_per_page, 
		'paged'          		=> $paged,
		'ignore_sticky_posts'	=> true,
	);

    // Category Parameter
	if($cat != "") {
		$args['tax_query'] = array(
								array( 
									'taxonomy' 	=> BDP_CAT,
									'terms' 	=> $cat,
									'field' 	=> ( isset($cat[0]) && is_numeric($cat[0]) ) ? 'term_id' : 'slug',
								));

	}

	// WP Query
	$query = new WP_Query( $args );

	ob_start();

	// If post is there
	if ( $query->have_posts() ) { ?>
		<div class="bdpgridbox-main <?php echo 'bdp-'.esc_attr( $design ); ?> bdp-clearfix">
			<div class="bdp-gridbox-inner bdp-clearfix">
				<?php while ( $query->have_posts() ) : $query->the_post();

					$css_class 				= '';
					$cat_links 				= array();
					$post_featured_image 	= bdp_get_post_featured_image( $post->ID );
					$post_link 				= bdp_get_post_link( $post->ID );
					$terms 					= get_the_terms( $post->ID, BDP_CAT );
					$tags 					= get_the_tag_list(' ', ', ');
					$comments 				= get_comments_number( $post->ID );
					$reply					= ($comments <= 1) ? __('Reply', 'blog-designer-pack') : __('Replies', 'blog-designer-pack');

					if( $terms ) {
						foreach ( $terms as $term ) {
							$term_link = get_term_link( $term );
							$cat_links[] = '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
						}
					}
					$cate_name = join( " ", $cat_links );

					// Include shortcode html file
					if( $design_file ) {
						include( $design_file );
					}
					$bdpcount++;
				endwhile; ?>
			</div>
		
			<?php if( $pagination == "true" && $query->max_num_pages > 1 ) { ?>
				<div class="bdp-post-pagination bdp-clearfix">
					<?php
						echo bdp_pagination( array( 'paged' => $paged , 'total' => $query->max_num_pages, 'multi_page' => $multi_page ) );
					?>
				</div>
				<?php } ?>
		</div>
		<?php 
	} // end of have_post()

	wp_reset_postdata(); // Reset WP Query

	$content .= ob_get_clean();
	return $content;
}

Code file location:

blog-designer-pack/blog-designer-pack/includes/shortcodes/bdp-post-gridbox.php

News & Blog Designer Pack [bdp_post_list] Shortcode

The Blog Designer Pack shortcode, ‘bdp_post_list’, is designed to generate a list of blog posts. It offers customizable attributes like post limit, category, design, and more. It allows users to control the visibility of author, date, category, content, tags, comments, and read more button. It also supports pagination and various media sizes.

Shortcode: [bdp_post_list]

Parameters

Here is a list of all possible bdp_post_list shortcode parameters and attributes:

  • limit – sets the maximum number of posts to display.
  • category – filters posts to specific category or categories.
  • design – chooses a design template for the posts.
  • show_author – decides whether to display the author’s name.
  • pagination – toggles pagination for the post list.
  • media_size – sets the size of the featured image.
  • show_date – determines if the post date is shown.
  • show_category – controls if the post category is displayed.
  • show_content – decides if the post content is shown.
  • show_tags – controls if the post tags are displayed.
  • show_comments – decides if the post comments are shown.
  • content_words_limit – limits the number of content words displayed.
  • show_read_more – toggles the display of a ‘read more’ link.
  • order – sets the order of the posts, ascending or descending.
  • orderby – determines the attribute by which posts are ordered.

Examples and Usage

Basic example – Display a list of posts with default parameters.

[bdp_post_list]

Advanced examples

Display a list of posts from a specific category, limit the number of posts, and customize the design.

[bdp_post_list category="news" limit="10" design="design-2"]

Show a list of posts without the author’s name, comments, and tags. Also, limit the content words to 50.

[bdp_post_list show_author="false" show_comments="false" show_tags="false" content_words_limit="50"]

Display a list of posts in ascending order by title, without pagination, and with a medium-sized featured image.

[bdp_post_list order="asc" orderby="title" pagination="false" media_size="medium"]

Using the shortcode to display a list of posts from multiple categories by referencing both categories. The posts will first try to load by the first category, but if not found, it will try to load by the second category.

[bdp_post_list category="news,sports"]

PHP Function Code

In case you have difficulties debugging what causing issues with [bdp_post_list] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bdp_post_list', 'bdp_get_posts_list' );

Shortcode PHP function:

function bdp_get_posts_list( $atts, $content = null ) {

	// Taking some globals
	global $post, $multipage;

	// Shortcode Parameters
	extract(shortcode_atts(array(
		'limit' 				=> 20,
		'category' 				=> '',
		'design' 				=> 'design-1',
		'show_author' 			=> 'true',
		'pagination' 			=> 'true',
		'media_size' 			=> 'large',
		'show_date' 			=> 'true',
		'show_category' 		=> 'true',
		'show_content' 			=> 'true',
		'show_tags'				=> 'true',
		'show_comments'			=> 'true',
		'content_words_limit' 	=> 20,
		'show_read_more' 		=> 'true',
		'order'					=> 'DESC',
		'orderby'				=> 'date',
		), $atts, 'bdp_post_list'));

	$shortcode_designs 	= bdp_recent_post_list_designs();	
	$posts_per_page 	= !empty($limit) 					? $limit 						: 20;
	$cat 				= (!empty($category))				? explode(',',$category) 		: '';
	$design 			= ($design && (array_key_exists(trim($design), $shortcode_designs))) ? trim( $design ) 	: 'design-1';
	$showAuthor 		= ($show_author == 'false')			? 'false'						: 'true';
	$pagination 		= ($pagination == 'false')			? 'false'						: 'true';
	$media_size 		= (!empty($media_size))				? $media_size 	: 'large'; //thumbnail, medium, large, full	
	$showDate 			= ( $show_date == 'false' ) 		? 'false'						: 'true';
	$showCategory 		= ( $show_category == 'false' )		? 'false' 						: 'true';
	$showContent 		= ( $show_content == 'false' ) 		? 'false' 						: 'true';
	$words_limit 		= !empty( $content_words_limit ) 	? $content_words_limit 			: 20;	
	$showreadmore 		= ( $show_read_more == 'false' )	? 'false' 						: 'true';
	$order 				= ( strtolower($order) == 'asc' ) 	? 'ASC' 						: 'DESC';
	$orderby 			= !empty($orderby)					? $orderby 						: 'date';
	$show_tags 			= ( $show_tags == 'false' ) 		? 'false'						: 'true';
	$show_comments 		= ( $show_comments == 'false' ) 	? 'false'						: 'true';
	$multi_page			= ( $multipage || is_single() ) 	? 1 							: 0;

	// Shortcode file
	$post_design_file_path 	= BDP_DIR . '/templates/list/' . $design . '.php';
	$design_file 			= (file_exists($post_design_file_path)) ? $post_design_file_path : '';

	// Pagination parameter
	if( $multi_page ) {
		$paged = isset( $_GET['bdpp-page'] ) ? $_GET['bdpp-page'] : 1;
	} elseif ( get_query_var( 'paged' ) ) {
		$paged = get_query_var('paged');
	} elseif ( get_query_var( 'page' ) ) {
		$paged = get_query_var( 'page' );
	} else {
		$paged = 1;
	}

	// WP Query Parameters
	$args = array(
		'post_type'				=> BDP_POST_TYPE,
		'post_status'			=> array('publish'),
		'order'					=> $order,
		'orderby'				=> $orderby, 
		'posts_per_page'		=> $posts_per_page,
		'paged'					=> $paged,
		'ignore_sticky_posts'	=> true,
	);

	// Category Parameter
	if( $cat != "" ) {
		$args['tax_query'] = array(
								array( 
									'taxonomy' 	=> BDP_CAT,
									'terms' 	=> $cat,
									'field' 	=> ( isset($cat[0]) && is_numeric($cat[0]) ) ? 'term_id' : 'slug',
								));
	}

	// WP Query
	$query = new WP_Query($args);

	ob_start();

	// If post is there
	if ( $query->have_posts() ) { ?>
		<div class="bdp-list-main <?php echo 'bdp-'.esc_attr( $design ); ?> bdp-clearfix">
			<?php while ( $query->have_posts() ) : $query->the_post();
				
				$cat_links 				= array();
				$css_class 				= '';
				$post_featured_image 	= bdp_get_post_featured_image( $post->ID, $media_size );
				$post_link 				= bdp_get_post_link( $post->ID );
				$terms 					= get_the_terms( $post->ID, BDP_CAT );
				$tags 					= get_the_tag_list(' ',', ');
				$comments 				= get_comments_number( $post->ID );				
				$reply					= ($comments <= 1) ? __('Reply', 'blog-designer-pack') : __('Replies', 'blog-designer-pack');

				if( $terms ) {
					foreach ( $terms as $term ) {
						$term_link = get_term_link( $term );
						$cat_links[] = '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
					}
				}
				$cate_name = join( " ", $cat_links );

				// Include shortcode html file
				if( $design_file ) {
					include( $design_file );
				}

			endwhile; ?>
		</div>		
		<?php if($pagination == "true" && $query->max_num_pages > 1 ) { ?>
		<div class="bdp-post-pagination bdp-clearfix">
			<?php
				echo bdp_pagination( array( 'paged' => $paged , 'total' => $query->max_num_pages, 'multi_page' => $multi_page ) );
			?>
		</div>
		<?php }
	} // end of have_post()

	wp_reset_postdata(); // Reset WP Query

	$content .= ob_get_clean();
	return $content;
}

Code file location:

blog-designer-pack/blog-designer-pack/includes/shortcodes/bdp-post-list.php

News & Blog Designer Pack [bdp_masonry] Shortcode

The Blog Designer Pack shortcode is a powerful tool that allows you to customize the display of blog posts on your WordPress site. This shortcode provides a range of parameters like limit, category, design, grid, pagination, etc. You can specify the number of posts to display, select specific categories, choose from different design templates, and much more. It also supports pagination and masonry layout for an attractive and user-friendly blog design.

Shortcode: [bdp_masonry]

Parameters

Here is a list of all possible bdp_masonry shortcode parameters and attributes:

  • limit – sets the maximum number of posts displayed.
  • category – filters posts by specified category.
  • design – chooses the layout design for the posts.
  • grid – determines the number of columns in the grid.
  • pagination – enables or disables pagination feature.
  • show_date – controls the visibility of the post date.
  • show_category – controls the visibility of the post category.
  • show_content – controls the visibility of the post content.
  • show_read_more – controls the visibility of the ‘read more’ button.
  • content_words_limit – sets a word limit for the post content.
  • order – sets the order of the posts (ascending or descending).
  • orderby – determines the parameter for ordering posts.
  • effect – selects the visual effect applied on the post.
  • load_more_text – customizes the text for the ‘load more’ button.
  • show_author – controls the visibility of the post author.
  • media_size – sets the size of the media in the post.
  • show_tags – controls the visibility of the post tags.
  • show_comments – controls the visibility of the post comments.

Examples and Usage

Basic example – A simple usage of the shortcode to display a masonry layout of blog posts. In this case, it will display the recent 10 posts.

[bdp_masonry limit="10" /]

Advanced examples

Displaying a masonry layout of blog posts from a specific category. Here, the category slug is ‘news’ and it will display the recent 5 posts from this category.

[bdp_masonry limit="5" category="news" /]

Displaying a masonry layout of blog posts with a specific design and grid structure. Here, the design is ‘design-2’, the grid structure is ‘3’ and it will display the recent 10 posts.

[bdp_masonry limit="10" design="design-2" grid="3" /]

Displaying a masonry layout of blog posts with a specific ordering. Here, it will display the recent 10 posts in ascending order by post date.

[bdp_masonry limit="10" order="ASC" orderby="date" /]

Displaying a masonry layout of blog posts with specific content visibility. In this case, it will display the recent 10 posts without the date, category, and read more button.

[bdp_masonry limit="10" show_date="false" show_category="false" show_read_more="false" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [bdp_masonry] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bdp_masonry', 'bdp_post_masonry' );

Shortcode PHP function:

function bdp_post_masonry( $atts, $content = null ) {

	// Taking some globals
	global $post, $multipage;

	// Shortcode Parameters
	extract(shortcode_atts(array(
		"limit" 				=> 10,
		"category" 				=> '',
		"design"	 			=> 'design-1',
		"grid" 					=> 2,
		"pagination" 			=> 'false',
		"show_date" 			=> 'true',
		"show_category"			=> 'true',
		"show_content" 			=> 'true',
		"show_read_more" 		=> 'true',
		"content_words_limit" 	=> 20,
		'order'					=> 'DESC',
		'orderby'				=> 'date',
		'effect'				=> 'effect-2',
		'load_more_text'		=> '',
		'show_author' 			=> 'true',
		'media_size' 			=> 'large',
		'show_tags'				=> 'true',
		'show_comments'			=> 'true',
	), $atts, 'bdp_masonry'));

	$shortcode_designs 	= bdp_post_masonry_designs();
	$msonry_effects 	= bdp_post_masonry_effects();
	$posts_per_page		= (!empty($limit)) 						? $limit 			: 10;
	$cat 				= (!empty($category))					? explode(',',$category) : '';		
	$design 			= ($design && (array_key_exists(trim($design), $shortcode_designs))) ? trim($design) 	: 'design-1';
	$pagination 		= ($pagination == 'true')				? 'true'			: 'false';
	$grid 				= (!empty($grid))						? $grid 			: 2;
	$showDate 			= ( $show_date == 'true' ) 				? 'true' 			: 'false';
	$showCategory 		= ( $show_category == 'true')			? 'true' 			: 'false';
	$showContent 		= ( $show_content == 'true' ) 			? 'true' 			: 'false';
	$words_limit 		= !empty($content_words_limit) 			? $content_words_limit : 20;
	$showreadmore 		= ( $show_read_more == 'true' ) 		? 'true' 			: 'false';
	$order 				= ( strtolower($order) == 'asc' ) 		? 'ASC' 			: 'DESC';
	$orderby 			= (!empty($orderby))					? $orderby			: 'post_date';
	$load_more_text 	= !empty($load_more_text) 				? $load_more_text 	: __('Load More Posts', 'blog-designer-pack');
	$effect 			= (!empty($effect) && array_key_exists(trim($effect), $msonry_effects))	? trim($effect) : 'effect-1';
	$showAuthor 		= ($show_author == 'false')				? 'false'			: 'true';
	$media_size 		= (!empty($media_size))					? $media_size 		: 'large'; //thumbnail, medium, large, full
	$show_tags 			= ( $show_tags == 'false' ) 			? 'false'			: 'true';
	$show_comments 		= ( $show_comments == 'false' ) 		? 'false'			: 'true';
	$multi_page			= ( $multipage || is_single() ) 		? 1 				: 0;
	$unique 			= bdp_get_unique();

	// Shortcode file
	$design_file_path 	= BDP_DIR . '/templates/masonry/' . $design . '.php';
	$design_file 		= (file_exists($design_file_path)) ? $design_file_path : '';

	// Shortcode Parameters
	$shortcode_atts = compact('posts_per_page', 'cat', 'design', 'pagination', 'grid', 'showDate', 'showCategory', 'showContent', 'words_limit', 'showreadmore', 'order', 'orderby', 'showAuthor', 'media_size', 'show_tags', 'show_comments');

	// Pagination parameter
	if( $multi_page ) {
		$paged = isset( $_GET['bdpp-page'] ) ? $_GET['bdpp-page'] : 1;
	} elseif ( get_query_var( 'paged' ) ) {
		$paged = get_query_var('paged');
	} elseif ( get_query_var( 'page' ) ) {
		$paged = get_query_var( 'page' );
	} else {
		$paged = 1;
	}

	// Enqueue required script
	wp_enqueue_script( 'masonry' );
	wp_enqueue_script( 'bdp-public-script' );
	bdp_enqueue_script();

	// WP Query Parameters
	$args = array (
		'post_type'      		=> BDP_POST_TYPE,
		'post_status' 			=> array('publish'),
		'order'          		=> $order,
		'orderby'        		=> $orderby, 
		'posts_per_page' 		=> $posts_per_page, 
		'paged'          		=> $paged,
		'ignore_sticky_posts'	=> true,
	);

	// Category Parameter
	if($cat != "") {
		$args['tax_query'] = array(
								array( 
									'taxonomy' 	=> BDP_CAT,
									'terms' 	=> $cat,
									'field' 	=> ( isset($cat[0]) && is_numeric($cat[0]) ) ? 'term_id' : 'slug',
								));
	} 

	// WP Query
	$query 		= new WP_Query($args);
	$total_post = $query->found_posts;

	ob_start();

	// If Blog post is there
	if ( $query->have_posts() ) : ?>
		<div class="bdp-post-masonry-wrp bdp-clearfix" id="bdp-post-masonry-wrp-<?php echo esc_attr( $unique ); ?>">
			<div class="bdp-post-masonry bdp-clearfix bdp-<?php echo esc_attr( $effect ); ?> bdp-<?php echo esc_attr( $design ); ?> bdpgrid-<?php echo esc_attr( $grid ); ?>" id="bdp-post-masonry-<?php echo esc_attr( $unique ); ?>">

				<?php while ( $query->have_posts() ) : $query->the_post();

					$cat_links 				= array();
					$terms 					= get_the_terms( $post->ID, BDP_CAT );
					$post_link 				= bdp_get_post_link( $post->ID );
					$post_featured_image 	= bdp_get_post_featured_image( $post->ID, $media_size );
					$tags 			        = get_the_tag_list(' ',', ');
					$comments 		        = get_comments_number( $post->ID );					
					$reply					= ($comments <= 1) ? __('Reply', 'blog-designer-pack') : __('Replies', 'blog-designer-pack');

					if( $terms ) {
						foreach ( $terms as $term ) {
							$term_link = get_term_link( $term );
							$cat_links[] = '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
						}
					}
					$cate_name = join( " ", $cat_links );

					if( $design_file ) {
						include( $design_file );
					}
					endwhile;
				?>
			</div>

			<?php if( ($posts_per_page != -1) && ($posts_per_page < $total_post) && ($pagination != 'true') ) { ?>
			<div class="bdp-ajax-btn-wrap bdp-clearfix" data-conf="<?php echo htmlspecialchars( json_encode($shortcode_atts)); ?>">
				<button class="bdp-load-more-btn more" data-ajax="1" data-paged="1">
					<i class="bdp-ajax-loader"><img src="<?php echo BDP_URL . 'assets/images/ajax-loader.gif'; ?>" alt="<?php esc_attr_e('Loading', 'blog-designer-pack'); ?>" /></i>
					<?php echo wp_kses_post( $load_more_text ); ?>
				</button>
			</div>
			<?php }

			if( $pagination == "true" && $query->max_num_pages > 1 ) { ?>
			<div class="bdp-post-pagination bdp-clearfix">
				<?php echo bdp_pagination( array( 'paged' => $paged , 'total' => $query->max_num_pages, 'multi_page' => $multi_page ) ); ?>
			</div>
			<?php } ?>
		</div>
	<?php
		endif;

	wp_reset_postdata(); // Reset wp query
	
	$content .= ob_get_clean();
	return $content;
}

Code file location:

blog-designer-pack/blog-designer-pack/includes/shortcodes/bdp-post-masonry.php

News & Blog Designer Pack [bdp_ticker] Shortcode

The Blog-Designer-Pack shortcode is a dynamic tool that enables the creation of a customized post ticker on your WordPress site. The shortcode extracts parameters such as theme color, font style, ticker effect, and more. It also allows specifying the number of posts to display (limit), post order, and category. The shortcode enqueues necessary scripts, sets up a query for fetching posts, and outputs a stylish post ticker. The ticker’s appearance is customizable via CSS.

Shortcode: [bdp_ticker]

Parameters

Here is a list of all possible bdp_ticker shortcode parameters and attributes:

  • limit – Determines the maximum number of posts to display.
  • ticker_title – Sets the title of the ticker.
  • theme_color – Defines the color scheme of the ticker.
  • heading_font_color – Sets the color of the ticker title.
  • font_color – Specifies the color of the ticker text.
  • font_style – Determines the style of the ticker text.
  • ticker_effect – Chooses the transition effect of the ticker.
  • autoplay – Determines if the ticker should autoplay.
  • speed – Sets the transition speed of the ticker in milliseconds.
  • category – Specifies the category of posts to display.
  • order – Sets the order of the posts, ascending or descending.
  • orderby – Determines the parameter to sort the posts by.

Examples and Usage

Basic example – Displaying the latest posts using the default settings of the ticker

[bdp_ticker /]

Advanced examples:

Customizing the ticker to display the 10 latest posts from a specific category (for example, “news”), ordered by title in ascending order, and with a custom title “Latest News”.

[bdp_ticker limit="10" category="news" order="ASC" orderby="title" ticker_title="Latest News" /]

Displaying a ticker with a unique color scheme and font style, where the ticker’s theme color is red, the font color is white, and the heading font color is black. The ticker effect is set to slide horizontally, and the speed is set to 2000 milliseconds.

[bdp_ticker theme_color="#ff0000" font_color="#ffffff" heading_font_color="#000000" ticker_effect="slide-h" speed="2000" /]

Using the shortcode to display a ticker without autoplay. The ticker will only move when the user interacts with the navigation buttons.

[bdp_ticker autoplay="false" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [bdp_ticker] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bdp_ticker', 'bdp_get_post_ticker' );

Shortcode PHP function:

function bdp_get_post_ticker( $atts, $content = null ) {

	// Shortcode Parameters
	extract(shortcode_atts(array(
		'limit' 				=> 20,
		'ticker_title'			=> __('Latest Post', 'blog-designer-pack'),
		'theme_color'			=> '#2096cd',
		'heading_font_color'	=> '#fff',
		'font_color'			=> '#2096cd',
		'font_style'			=> 'normal',
		'ticker_effect'			=> 'slide-v',
		'autoplay'				=> 'true',
		'speed'					=> 3000,
		'category' 				=> '',
		'order'					=> 'DESC',
		'orderby'				=> 'date',
	), $atts, 'bdp_ticker'));

	$limit				= (!empty($limit)) 					? $limit 						: 20;
	$ticker_title		= !empty($ticker_title)				? $ticker_title					: '';
	$cat 				= (!empty($category))				? explode(',',$category) 		: '';  
	$order 				= ( strtolower($order) == 'asc' ) 	? 'ASC' 						: 'DESC';
	$orderby 			= (!empty($orderby))				? $orderby						: 'date';
	$theme_color		= !empty($theme_color)				? $theme_color					: '#2096cd';
	$font_color			= !empty($font_color)				? $font_color					: '#2096cd';
	$heading_font_color	= !empty($heading_font_color)		? $heading_font_color			: '#fff';
	$ticker_effect		= !empty($ticker_effect)			? $ticker_effect				: 'fade';
	$autoplay 			= ($autoplay == 'false')			? 'false'						: 'true';
	$speed 				= !empty($speed)					? $speed						: 3000;
	$unique				= bdp_get_unique();

	// Enqueue required script
	wp_enqueue_script( 'bdp-ticker-script' );
	wp_enqueue_script( 'bdp-public-script' );
	bdp_enqueue_script();

	// Taking some globals
	global $post;

	// Ticker configuration
	$ticker_conf = compact( 'ticker_effect', 'autoplay', 'speed', 'font_style' );

	// Query Parameter
	$args = array (
		'post_type'				=> BDP_POST_TYPE,
		'post_status'			=> array( 'publish' ),
		'order'					=> $order,
		'orderby'				=> $orderby,
		'posts_per_page'		=> $limit,
		'ignore_sticky_posts'	=> true,
		
	);

	// Category Parameter
	if( ! empty( $cat ) ) {
		$args['tax_query'] = array(
								array(
									'taxonomy' 	=> BDP_CAT,
									'terms' 	=> $cat,
									'field' 	=> ( isset($cat[0]) && is_numeric($cat[0]) ) ? 'term_id' : 'slug',
							));
	}

	// WP Query
	$query = new WP_Query( $args );

	ob_start();

	// If post is there
	if ( $query->have_posts() ) {
?>

	<style type="text/css">
		#bdp-ticker-<?php echo esc_attr( $unique ); ?>{border-color:<?php echo esc_attr( $theme_color ); ?>;}
		#bdp-ticker-<?php echo esc_attr( $unique ); ?> >.bdp-ticker-title{background:<?php echo esc_attr( $theme_color ); ?>;}
		#bdp-ticker-<?php echo esc_attr( $unique ); ?> >.bdp-ticker-title>span{border-left-color:<?php echo esc_attr( $theme_color ); ?>;}
		#bdp-ticker-<?php echo esc_attr( $unique ); ?> >ul>li>a:hover, #bdp-ticker-<?php echo esc_attr( $unique ); ?>>ul>li>a{color:<?php echo esc_attr( $font_color ); ?>;}
		#bdp-ticker-<?php echo esc_attr( $unique ); ?> > .bdp-ticker-title > .bdp-ticker-title-cnt{color: <?php echo esc_attr( $heading_font_color ); ?>}
	</style>

	<div class="bdp-ticker-wrp bdp-clearfix" id="bdp-ticker-<?php echo esc_attr( $unique ); ?>">
		<div class="bdp-ticker-title bdp-ticker-title">
			<?php if( $ticker_title ) { ?>
			<div class="bdp-ticker-title-cnt"><?php echo esc_html( $ticker_title ); ?></div>
			<?php } ?>
			<span></span>
		</div>
		<ul class="bdp-ticker-cnt">
			<?php while ( $query->have_posts() ) : $query->the_post();
				$post_link = bdp_get_post_link( $post->ID );
			?>
			<li class="bdp-ticker-ele"><a href="<?php echo esc_url( $post_link ); ?>"><?php the_title(); ?></a></li>
			<?php endwhile; ?>
		</ul>
		<div class="bdp-ticker-navi bdp-ticker-navi">
			<span></span>
			<span></span>
		</div>
		<div class="bdp-ticker-conf"><?php echo htmlspecialchars(json_encode($ticker_conf)); ?></div>
	</div>

<?php
	} // End of have_post()

	wp_reset_postdata(); // Reset WP Query

	$content .= ob_get_clean();
	return $content;
}

Code file location:

blog-designer-pack/blog-designer-pack/includes/shortcodes/bdp-post-ticker.php

News & Blog Designer Pack [bdp_post] Shortcode

The Blog Designer Pack shortcode enables a customizable display of posts. It retrieves posts based on various parameters such as limit, category, design, grid layout, and more. It also controls the visibility of elements like author, tags, comments, and date.

Shortcode: [bdp_post]

Parameters

Here is a list of all possible bdp_post shortcode parameters and attributes:

  • limit – sets the maximum number of posts to display.
  • category – displays posts from specific categories only.
  • grid – sets the number of columns in the post grid.
  • design – selects the layout design for the posts.
  • show_author – controls whether the author’s name is displayed.
  • show_tags – controls whether the post tags are displayed.
  • show_comments – controls whether the comment count is displayed.
  • show_category – controls whether the post category is displayed.
  • show_content – controls whether the post content is displayed.
  • show_date – controls whether the post date is displayed.
  • pagination – controls whether pagination is displayed.
  • media_size – sets the size of the featured image.
  • content_words_limit – sets the maximum word count for post content.
  • show_read_more – controls whether the ‘Read More’ button is displayed.
  • order – sets the order of the posts (ASC or DESC).
  • orderby – sets the parameter by which posts are ordered.

Examples and Usage

Basic example – Display posts using the default parameters set in the shortcode function.

[bdp_post /]

Advanced examples

Displaying posts from a specific category. This shortcode will display a maximum of 10 posts from the category with the slug ‘news’ in a two-column grid layout.

[bdp_post limit="10" category="news" grid="2" /]

Displaying posts with specific attributes. This shortcode will display posts with the ‘design-2’ layout, without author, tags, comments, and category information. It will also limit the content to 50 words and remove the ‘read more’ option.

[bdp_post design="design-2" show_author="false" show_tags="false" show_comments="false" show_category="false" show_content="true" content_words_limit="50" show_read_more="false" /]

Sorting posts by title in ascending order. This shortcode will display posts ordered by title in ascending order, rather than the default date-based descending order.

[bdp_post order="asc" orderby="title" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [bdp_post] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bdp_post', 'bdp_get_posts' );

Shortcode PHP function:

function bdp_get_posts( $atts, $content = null ) {

	// Taking some globals
	global $post, $multipage;

	// Shortcode Parameters
	extract(shortcode_atts(array(
		'limit' 				=> 20,
		'category' 				=> '',
		'grid' 					=> 1,
		'design' 				=> 'design-1',
		'show_author' 			=> 'true',
		'show_tags'				=> 'true',
		'show_comments'			=> 'true',
		'show_category' 		=> 'true',
		'show_content' 			=> 'true',
		'show_date' 			=> 'true',
		'pagination' 			=> 'true',
		'media_size' 			=> 'large',
		'content_words_limit' 	=> 20,
		'show_read_more' 		=> 'true',
		'order'					=> 'DESC',
		'orderby'				=> 'date',
		), $atts, 'bdp_post'));

	$shortcode_designs 	= bdp_post_designs();
	$posts_per_page 	= !empty($limit) 					? $limit 						: 20;
	$cat 				= (!empty($category))				? explode(',',$category) 		: '';
	$grid				= !empty($grid) 					? $grid 						: 1;
	$design 			= ($design && (array_key_exists(trim($design), $shortcode_designs))) ? trim($design) 	: 'design-1';
	$showAuthor 		= ($show_author == 'false')			? 'false'						: 'true';
	$show_tags 			= ( $show_tags == 'false' ) 		? 'false'						: 'true';
	$show_comments 		= ( $show_comments == 'false' ) 	? 'false'						: 'true';
	$showDate 			= ( $show_date == 'false' ) 		? 'false'						: 'true';
	$showCategory 		= ( $show_category == 'false' )		? 'false' 						: 'true';
	$showContent 		= ( $show_content == 'false' ) 		? 'false' 						: 'true';
	$pagination 		= ($pagination == 'false')			? 'false'						: 'true';
	$media_size 		= (!empty($media_size))				? $media_size 					: 'large'; //thumbnail, medium, large, full
	$words_limit 		= !empty( $content_words_limit ) 	? $content_words_limit 			: 20;
	$showreadmore 		= ( $show_read_more == 'false' )	? 'false' 						: 'true';
	$order 				= ( strtolower($order) == 'asc' ) 	? 'ASC' 						: 'DESC';
	$orderby 			= !empty($orderby)					? $orderby 						: 'date';
	$multi_page			= ( $multipage || is_single() ) 	? 1 							: 0;

	// Shortcode file
	$post_design_file_path 	= BDP_DIR . '/templates/grid/' . $design . '.php';
	$design_file 			= (file_exists($post_design_file_path)) ? $post_design_file_path : '';

	// Taking some variables
	$count = 0;

	// Pagination parameter
	if( $multi_page ) {
		$paged = isset( $_GET['bdpp-page'] ) ? $_GET['bdpp-page'] : 1;
	} elseif ( get_query_var( 'paged' ) ) {
		$paged = get_query_var('paged');
	} elseif ( get_query_var( 'page' ) ) {
		$paged = get_query_var( 'page' );
	} else {
		$paged = 1;
	}

	// WP Query Parameters
	$args = array ( 
		'post_type'				=> BDP_POST_TYPE,
		'post_status'			=> array('publish'),
		'order'					=> $order,
		'orderby'				=> $orderby,
		'posts_per_page'		=> $posts_per_page,
		'paged'					=> $paged,
		'ignore_sticky_posts'	=> true,
	);

	// Category Parameter
	if( $cat != "" ) {
		$args['tax_query'] = array(
								array(
									'taxonomy' 	=> BDP_CAT,
									'terms' 	=> $cat,
									'field' 	=> ( isset($cat[0]) && is_numeric($cat[0]) ) ? 'term_id' : 'slug',
								));
	}

	// WP Query
	$query = new WP_Query($args);

	ob_start();

	// If post is there
	if ( $query->have_posts() ) { ?>

		<div class="bdp-post-grid-main <?php echo 'bdp-'.esc_attr( $design ); ?> bdpgrid-<?php echo esc_attr( $grid ); ?> bdp-clearfix">
			<?php
			while ( $query->have_posts() ) : $query->the_post();
				
				$count++;
				$cat_links 				= array();
				$css_class 				= '';
				$post_featured_image 	= bdp_get_post_featured_image( $post->ID, $media_size );
				$post_link 				= bdp_get_post_link( $post->ID );
				$terms 					= get_the_terms( $post->ID, BDP_CAT );
				$tags 					= get_the_tag_list(' ',', ');
				$comments 				= get_comments_number( $post->ID );
				$reply					= ($comments <= 1)  ? __('Reply', 'blog-designer-pack') : __('Replies', 'blog-designer-pack');

				if( $terms ) {
					foreach ( $terms as $term ) {
						$term_link = get_term_link( $term );
						$cat_links[] = '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
					}
				}
				$cate_name = join( " ", $cat_links );
				$css_class .= ( $count % $grid  == 1 ) ? ' bdp-first' : '';

				// Include shortcode html file
				if( $design_file ) {
					include( $design_file );
				}

			endwhile; ?>
		</div>

		<?php if( $pagination == "true" && $query->max_num_pages > 1 ) { ?>
			<div class="bdp-post-pagination bdp-clearfix">
				<?php
					echo bdp_pagination( array( 'paged' => $paged , 'total' => $query->max_num_pages, 'multi_page' => $multi_page ) );
				?>
			</div>
		<?php }
	} // end of have_post()

	wp_reset_postdata(); // Reset WP Query

	$content .= ob_get_clean();
	return $content;
}

Code file location:

blog-designer-pack/blog-designer-pack/includes/shortcodes/bdp-post.php

News & Blog Designer Pack [bdp_post_carousel] Shortcode

The Blog-Designer-Pack shortcode, ‘bdp_post_carousel’, generates a customizable post carousel. It enables users to define parameters such as post limit, categories, design, and display settings.

Shortcode: [bdp_post_carousel]

Parameters

Here is a list of all possible bdp_post_carousel shortcode parameters and attributes:

  • limit – Specifies the number of posts to show.
  • category – Filters posts by specified category.
  • show_read_more – Toggles the display of the ‘read more’ link.
  • design – Selects the design template for the carousel.
  • show_author – Toggles the display of the post author.
  • show_date – Toggles the display of the post date.
  • show_category – Toggles the display of the post category.
  • show_content – Toggles the display of the post content.
  • content_words_limit – Limits the number of words in the post content.
  • slide_show – Determines the number of slides to show.
  • slide_scroll – Determines the number of slides to scroll.
  • media_size – Sets the size of the post’s media.
  • dots – Toggles the display of navigation dots.
  • arrows – Toggles the display of navigation arrows.
  • autoplay – Toggles the autoplay feature of the carousel.
  • autoplay_interval – Sets the time interval for autoplay.
  • speed – Sets the animation speed of the carousel.
  • loop – Toggles the loop feature of the carousel.
  • order – Sets the order of the posts.
  • orderby – Determines the parameter to order posts by.
  • show_tags – Toggles the display of post tags.
  • show_comments – Toggles the display of the number of comments.

Examples and Usage

Basic example – Display a carousel of your recent blog posts with default settings.

[bdp_post_carousel]

Advanced examples

Display a carousel of your recent blog posts from a specific category (for example, ‘news’), limit the number of posts to 10, and disable the display of the post author and post date.

[bdp_post_carousel limit="10" category="news" show_author="false" show_date="false"]

Display a carousel of your recent blog posts with a custom design, change the slide show to display 5 posts at a time, and adjust the autoplay interval to 5000 milliseconds.

[bdp_post_carousel design="design-2" slide_show="5" autoplay_interval="5000"]

Display a carousel of your recent blog posts, order the posts in ascending order by title, and disable the display of post tags and comments.

[bdp_post_carousel order="ASC" orderby="title" show_tags="false" show_comments="false"]

PHP Function Code

In case you have difficulties debugging what causing issues with [bdp_post_carousel] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bdp_post_carousel', 'bdp_post_carousel' );

Shortcode PHP function:

function bdp_post_carousel( $atts, $content = null ) {

	// Shortcode Parameters
	extract(shortcode_atts(array(
		'limit' 				=> 20,
		'category' 				=> '',
		'show_read_more' 		=> 'true',
		'design' 				=> 'design-1',
		'show_author' 			=> 'true',
		'show_date' 			=> 'true',
		'show_category' 		=> 'true',
		'show_content' 			=> 'false',
		'content_words_limit' 	=> 20,
		'slide_show'            => 3,
		'slide_scroll'          => 1,
		'media_size' 			=> 'large',
		'dots' 					=> 'true',
		'arrows'				=> 'true',
		'autoplay' 				=> 'true',
		'autoplay_interval' 	=> 3000,
		'speed' 				=> 600,
		'loop' 					=> 'true',
		'order'					=> 'DESC',
		'orderby'				=> 'date',
		'show_tags'				=> 'true',
		'show_comments'			=> 'true',
		), $atts, 'bdp_post_carousel'));

	$shortcode_designs 		= bdp_recent_post_carousel_designs();
	$posts_per_page 		= !empty($limit) 						? $limit 						: 20;
	$cat 					= (!empty($category))					? explode(',',$category) 		: '';
	$slide_show 			= !empty($slide_show) 					? $slide_show 					: 3;
	$slide_scroll 			= !empty($slide_scroll) 				? $slide_scroll 				: 1;
	$design 				= ($design && (array_key_exists(trim($design), $shortcode_designs))) ? trim($design) 	: 'design-1';
	$showDate 				= ( $show_date == 'false' ) 			? 'false'						: 'true';
	$showCategory 			= ( $show_category == 'false' )			? 'false' 						: 'true';
	$showContent 			= ( $show_content == 'false' ) 			? 'false' 						: 'true';
	$media_size 			= (!empty($media_size))					? $media_size 					: 'large'; //thumbnail, medium, large, full	
	$words_limit 			= !empty( $content_words_limit ) 		? $content_words_limit	 		: 20;
	$dots 					= ( $dots == 'false' )					? 'false' 						: 'true';
	$arrows 				= ( $arrows == 'false' )				? 'false' 						: 'true';
	$autoplay 				= ( $autoplay == 'false' )				? 'false' 						: 'true';
	$autoplay_interval 		= !empty( $autoplay_interval ) 			? $autoplay_interval 			: 2000;
	$speed 					= !empty( $speed ) 						? $speed 						: 300;
	$loop 					= ( $loop == 'false' )					? 'false' 						: 'true';
	$showAuthor 			= ($show_author == 'false')				? 'false'						: 'true';
	$order 					= ( strtolower($order) == 'asc' ) 		? 'ASC' 						: 'DESC';
	$orderby 				= !empty($orderby) 						? $orderby 						: 'date';
	$show_tags 				= ( $show_tags == 'false' ) 			? 'false'						: 'true';
	$show_comments 			= ( $show_comments == 'false' ) 		? 'false'						: 'true';
	$showreadmore 			= ( $show_read_more == 'false' ) 		? 'false'						: 'true';
	
	// Shortcode file
	$post_design_file_path 	= BDP_DIR . '/templates/carousel/' . $design . '.php';
	$design_file 			= (file_exists($post_design_file_path)) ? $post_design_file_path : '';
	
	// Slider configuration
	$slider_conf = compact('slide_show', 'slide_scroll', 'dots', 'arrows', 'autoplay', 'autoplay_interval', 'speed', 'loop', 'design');
	
	// Enqueue required script
	wp_enqueue_script( 'jquery-slick' );
	wp_enqueue_script( 'bdp-public-script' );
	bdp_enqueue_script();

	// Taking some globals
	global $post;

	// Taking some variables
	$unique	= bdp_get_unique();

	// WP Query Parameters
	$args = array ( 
				'post_type'				=> BDP_POST_TYPE,
				'post_status'			=> array( 'publish' ),
				'orderby'				=> $orderby, 
				'order'					=> $order,
				'posts_per_page'		=> $posts_per_page,
				'ignore_sticky_posts'	=> true,
			);

	// Category Parameter
	if( $cat != "" ) {
		$args['tax_query'] = array(
								array(
									'taxonomy' 	=> BDP_CAT,
									'terms' 	=> $cat,
									'field' 	=> ( isset($cat[0]) && is_numeric($cat[0]) ) ? 'term_id' : 'slug',
								));

	} 

	// WP Query
	$query = new WP_Query( $args );

	ob_start();

	// If post is there
	if ( $query->have_posts() ) { ?>

	<div class="bdp-post-carousel-wrp bdp-clearfix">
		<div class="bdp-post-carousel <?php echo 'bdp-'.esc_attr( $design ); ?>"  id="bdp-carousel-<?php echo esc_attr( $unique ); ?>">
			<?php while ( $query->have_posts() ) : $query->the_post();

				$cat_links	= array();
				$terms 		= get_the_terms( $post->ID, BDP_CAT );

				if( $terms ) {
					foreach ( $terms as $term ) {
						$term_link		= get_term_link( $term );
						$cat_links[]	= '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
					}
				}
				$cate_name 		= join( " ", $cat_links );

				$post_featured_image 	= bdp_get_post_featured_image( $post->ID, $media_size );
				$post_link 				= bdp_get_post_link( $post->ID );
				$tags 					= get_the_tag_list(' ',', ');
				$comments 				= get_comments_number( $post->ID );
				$reply					= ($comments <= 1) ? __('Reply', 'blog-designer-pack') : __('Replies', 'blog-designer-pack');
				
				// Include shortcode html file
				if( $design_file ) {
					include( $design_file );
				}

			endwhile;
		?>
		</div>
		<div class="bdp-slider-conf"><?php echo htmlspecialchars(json_encode( $slider_conf )); ?></div>
	</div>

	<?php
	} // End of have_post()
	
	wp_reset_postdata(); // Reset WP Query
	
	$content .= ob_get_clean();
	return $content;
}

Code file location:

blog-designer-pack/blog-designer-pack/includes/shortcodes/bdp-recent-post-carousel.php

News & Blog Designer Pack [bdp_post_slider] Shortcode

The Blog Designer Pack shortcode, ‘bdp_post_slider’, is used to create a customizable post slider on your webpage. It enables you to control the number of posts displayed, the category of posts, and the design of the slider. You can also adjust the visibility of elements such as the author, date, categories, content, tags, and comments. The speed, autoplay interval, and order of posts can be defined too. This shortcode provides a dynamic way to showcase your content.

Shortcode: [bdp_post_slider]

Parameters

Here is a list of all possible bdp_post_slider shortcode parameters and attributes:

  • limit – Specifies the maximum number of posts to display.
  • category – Filters posts based on their categories.
  • show_read_more – Controls whether to show a ‘read more’ link.
  • design – Selects the design template for the blog posts.
  • show_author – Controls whether to display the post author’s name.
  • show_date – Controls whether to display the date of the post.
  • show_category – Controls whether to display the post’s category.
  • show_content – Controls whether to display the post content.
  • content_words_limit – Sets the maximum number of words for the post content.
  • media_size – Sets the size of the media item in the post.
  • dots – Controls whether to display navigation dots in the slider.
  • arrows – Controls whether to display navigation arrows in the slider.
  • autoplay – Controls whether the slider plays automatically.
  • autoplay_interval – Sets the interval for automatic slider playback.
  • speed – Sets the speed of the slider transition.
  • loop – Controls whether the slider loops back to the start.
  • order – Sets the order of posts, ascending or descending.
  • orderby – Sets the parameter by which posts are ordered.
  • show_tags – Controls whether to display the post’s tags.
  • show_comments – Controls whether to display the number of comments.

Examples and Usage

Basic example – A simple usage of the blog-designer-pack plugin shortcode to display a post slider with default settings.

[bdp_post_slider]

Advanced examples

Display a post slider with a limit of 10 posts, from a specific category, and without showing the author’s name.

[bdp_post_slider limit="10" category="news" show_author="false"]

Display a post slider with a limit of 5 posts, with a specific design, without showing the date, category, and content, and with medium size media.

[bdp_post_slider limit="5" design="design-2" show_date="false" show_category="false" show_content="false" media_size="medium"]

Display a post slider with a limit of 15 posts, with autoplay off, a speed of 1000, and without loop.

[bdp_post_slider limit="15" autoplay="false" speed="1000" loop="false"]

Display a post slider with a limit of 20 posts, ordered by title in ascending order, without showing tags and comments.

[bdp_post_slider limit="20" order="ASC" orderby="title" show_tags="false" show_comments="false"]

PHP Function Code

In case you have difficulties debugging what causing issues with [bdp_post_slider] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bdp_post_slider', 'bdp_post_slider' );

Shortcode PHP function:

function bdp_post_slider( $atts, $content = null ) {
	
	// Shortcode Parameters
	extract(shortcode_atts(array(
		'limit' 				=> 20,
		'category' 				=> '',
		'show_read_more' 		=> 'true',
		'design' 				=> 'design-1',
		'show_author' 			=> 'true',
		'show_date' 			=> 'true',
		'show_category' 		=> 'true',
		'show_content' 			=> 'true',
		'content_words_limit' 	=> 20,	
		'media_size' 			=> 'large',
		'dots' 					=> 'true',
		'arrows'				=> 'true',
		'autoplay' 				=> 'true',
		'autoplay_interval' 	=> 3000,
		'speed' 				=> 600,
		'loop' 					=> 'true',
		'order'					=> 'DESC',
		'orderby'				=> 'date',
		'show_tags'				=> 'true',
		'show_comments'			=> 'true',
		), $atts, 'bdp_post_slider'));

	$shortcode_designs 		= bdp_recent_post_slider_designs();
	
	$posts_per_page 		= !empty($limit) 						? $limit 						: 20;
	$cat 					= (!empty($category))					? explode(',',$category) 		: '';
	$design 				= ($design && (array_key_exists(trim($design), $shortcode_designs))) ? trim($design) : 'design-1';
	$showDate 				= ( $show_date == 'false' ) 			? 'false'						: 'true';
	$showCategory 			= ( $show_category == 'false' )			? 'false' 						: 'true';
	$showContent 			= ( $show_content == 'false' ) 			? 'false' 						: 'true';
	$media_size 			= (!empty($media_size))					? $media_size					: 'large'; //thumbnail, medium, large, full	
	$words_limit 			= !empty( $content_words_limit ) 		? $content_words_limit	 		: 20;	
	$dots 					= ( $dots == 'false' )					? 'false' 						: 'true';
	$arrows 				= ( $arrows == 'false' )				? 'false' 						: 'true';
	$autoplay 				= ( $autoplay == 'false' )				? 'false' 						: 'true';
	$autoplay_interval 		= !empty( $autoplay_interval ) 			? $autoplay_interval 			: 3000;
	$speed 					= !empty( $speed ) 						? $speed 						: 600;
	$loop 					= ( $loop == 'false' )					? 'false' 						: 'true';
	$showAuthor 			= ($show_author == 'false')				? 'false'						: 'true';
	$order 					= ( strtolower($order) == 'asc' ) 		? 'ASC' 						: 'DESC';
	$orderby 				= !empty($orderby) 						? $orderby 						: 'date';
	$show_tags 				= ( $show_tags == 'false' ) 			? 'false'						: 'true';
	$show_comments 			= ( $show_comments == 'false' ) 		? 'false'						: 'true';
	$showreadmore 			= ( $show_read_more == 'false' ) 		? 'false'						: 'true';
	
	// Shortcode file
	$post_design_file_path 	= BDP_DIR . '/templates/slider/' . $design . '.php';
	$design_file 			= (file_exists($post_design_file_path)) ? $post_design_file_path : '';
	
	// Slider configuration
	$slider_conf = compact('dots', 'arrows', 'autoplay', 'autoplay_interval', 'speed', 'loop', 'design');
	
	// Enqueue required script
	wp_enqueue_script( 'jquery-slick' );
	wp_enqueue_script( 'bdp-public-script' );
	bdp_enqueue_script();

	// Taking some globals
	global $post;

	// Taking some variables
	$unique	= bdp_get_unique();

	// WP Query Parameters
	$args = array ( 
				'post_type'				=> BDP_POST_TYPE,
				'post_status'			=> array( 'publish' ),
				'orderby'				=> $orderby, 
				'order'					=> $order,
				'posts_per_page'		=> $posts_per_page,
				'ignore_sticky_posts'	=> true,
			);
	
	// Category Parameter
	if($cat != "") {

		$args['tax_query'] = array(
								array(
									'taxonomy' 	=> BDP_CAT,
									'terms' 	=> $cat,
									'field' 	=> ( isset($cat[0]) && is_numeric($cat[0]) ) ? 'term_id' : 'slug',
								));

	} 

	// WP Query
	$query = new WP_Query( $args );

	ob_start();

	// If post is there
	if ( $query->have_posts() ) { ?>

	<div class="bdp-post-slider-wrp bdp-clearfix">
		<div class="bdp-post-slider <?php echo 'bdp-'.esc_attr( $design ); ?>" id="bdp-slider-<?php echo esc_attr( $unique ); ?>">
			<?php while ( $query->have_posts() ) : $query->the_post();
				
				$cat_links	= array();
				$terms 		= get_the_terms( $post->ID, BDP_CAT );
				
				if( $terms ) {
					foreach ( $terms as $term ) {
						$term_link		= get_term_link( $term );
						$cat_links[]	= '<a href="' . esc_url( $term_link ) . '">'.$term->name.'</a>';
					}
				}
				$cate_name 		= join( " ", $cat_links );

				$feat_image 	= bdp_get_post_featured_image( $post->ID, $media_size );
				$post_link 		= bdp_get_post_link( $post->ID );
				$tags 			= get_the_tag_list(' ',', ');
				$comments 		= get_comments_number( $post->ID );
				$reply			= ($comments <= 1) ? __('Reply', 'blog-designer-pack') : __('Replies', 'blog-designer-pack');
				
				// Include shortcode html file
				if( $design_file ) {
					include( $design_file );
				}
				
			endwhile;
		?>
		</div>
		<div class="bdp-slider-conf"><?php echo htmlspecialchars(json_encode( $slider_conf )); ?></div>
	</div>

	<?php
	} // End of have_post()

	wp_reset_postdata(); // Reset WP Query

	$content .= ob_get_clean();
	return $content;
}

Code file location:

blog-designer-pack/blog-designer-pack/includes/shortcodes/bdp-recent-post-slider.php

Conclusion

Now that you’ve learned how to embed the News & Blog Designer Pack Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *