Sitekit Shortcodes

Below, you’ll find a detailed guide on how to add the Sitekit 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 Sitekit Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Sitekit Plugin and the shortcodes it provides:

Plugin Icon
Sitekit

"Sitekit is a powerful WordPress plugin designed to enhance your website's functionality. It simplifies site management, offering tools for SEO, speed optimization, and more. Elevate your WordPress experience with Sitekit."

★★★★★ (1) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [sitekit_archives]
  • [sitekit_bloginfo]
  • [sitekit_categories]
  • [sitekit_iframe]
  • []

Sitekit [sitekit_archives] Shortcode

The Sitekit Archives shortcode is a powerful tool for displaying your website’s archives. This shortcode allows you to specify the type of archives to display (yearly, monthly, weekly, daily, or post-by-post), limit the number of entries, format the output, and more.

Shortcode: [sitekit_archives]

Parameters

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

  • type – Specifies the type of archive to display (yearly, monthly, weekly, daily, postbypost, alpha).
  • limit – Sets the maximum number of archives to show.
  • format – Defines the format of the archive list (html, option).
  • before – Text or HTML to place before each archive.
  • after – Text or HTML to place after each archive.
  • show_post_count – If set to 1, displays the number of posts in each archive.
  • echo – If set to 0, returns the archive list instead of echoing it.
  • order – Sets the order of the archives (ASC, DESC).

Examples and Usage

Basic example – Display the archives in a monthly format with the default settings.

[sitekit_archives]

Advanced examples

Display the archives in a yearly format as an HTML unordered list, showing the post count, and in ascending order.

[sitekit_archives type="yearly" format="html" show_post_count="1" order="ASC"]

Display the archives in a daily format as a dropdown, without showing the post count, and in descending order.

[sitekit_archives type="daily" format="option" show_post_count="0" order="DESC"]

Display the archives in an alpha format (sorted by post title) as plain text, showing the post count, and in ascending order.

[sitekit_archives type="alpha" format="other" show_post_count="1" order="ASC"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sitekit_archives', 'sitekit_shortcode_archives' );

Shortcode PHP function:

function sitekit_shortcode_archives( $atts ) {
	$defaults = array(
		'type' => 'monthly',
		'limit' => '',
		'format' => 'html',
		'before' => '',
		'after' => '',
		'show_post_count' => 0,
		'echo' => 0,
		'order' => 'DESC'
	);
	$atts_obj = shortcode_atts( $defaults, $atts );
	
	$archives = wp_get_archives( $atts_obj );
	
	if ( $atts_obj['format'] == 'option' ) { // Archives as a dropdown

		// Create a title for the drop-down based on the archive type
		if ( $atts_obj['type'] == 'yearly' ) {
			$option_title = __( 'Select Year', 'sitekit' );

		} elseif ( $atts_obj['type'] == 'monthly' ) {
			$option_title = __( 'Select Month', 'sitekit' );

		} elseif ( $atts_obj['type'] == 'weekly' ) {
			$option_title = __( 'Select Week', 'sitekit' );

		} elseif ( $atts_obj['type'] == 'daily' ) {
			$option_title = __( 'Select Day', 'sitekit' );

		} elseif ( $atts_obj['type'] == 'postbypost' || $atts_obj['type'] == 'alpha' ) {
			$option_title = __( 'Select Post', 'sitekit' );
		}
		// Output the <select> element and each <option>
		$archives_output = '<p class="sitekit-archives"><select name="archive-dropdown" onchange=\'document.location.href=this.options[this.selectedIndex].value;\'>';
			$archives_output .= '<option value="">' . $option_title . '</option>';
			$archives_output .= $archives;
		$archives_output .= '</select></p><!-- .sitekit-archives -->';
		
	} elseif ( $atts_obj['format'] == 'html' ) { // Archives as an unordered list

		$archives_output = '<ul class="sitekit-archives">' . $archives . '</ul><!-- .sitekit-archives -->';

	} else { // Other formats

		$archives_output = $archives;

	}
	
	return $archives_output . SITEKIT_PLUGIN_POWERED;
}

Code file location:

sitekit/sitekit/inc/sitekit-shortcode-archives.php

Sitekit [sitekit_bloginfo] Shortcode

The Sitekit Bloginfo shortcode is a useful tool for WordPress users. It allows retrieval of information about the blog by using get_bloginfo() function. This shortcode accepts an attribute ‘show’ which defaults to ‘name’. Depending on the ‘show’ attribute, it returns the blog name, description, URL, or other blog information.

Shortcode: [sitekit_bloginfo]

Parameters

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

  • show – defines what blog information to display

Examples and Usage

Basic example – A simple way to use the ‘sitekit_bloginfo’ shortcode is to display the name of the blog. Here’s how you can do it:

[sitekit_bloginfo show="name" /]

With this shortcode, you can easily display the name of your blog anywhere on your site where shortcodes are supported.

Advanced examples

One of the powerful features of the ‘sitekit_bloginfo’ shortcode is its ability to display different types of information based on the ‘show’ attribute. For instance, you can use it to display the description of your blog:

[sitekit_bloginfo show="description" /]

This shortcode will return the description of your blog, as defined in your WordPress settings.

You can also use the ‘sitekit_bloginfo’ shortcode to display the URL of your blog. Here’s how:

[sitekit_bloginfo show="url" /]

The above shortcode will return the URL of your blog, allowing you to easily insert it into your posts or pages.

PHP Function Code

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

Shortcode line:

add_shortcode( 'sitekit_bloginfo', 'sitekit_shortcode_bloginfo' );

Shortcode PHP function:

function sitekit_shortcode_bloginfo( $atts ) {
	extract(shortcode_atts(array(
		'show' => 'name'
	), $atts));
	return get_bloginfo($show);
}

Code file location:

sitekit/sitekit/inc/sitekit-shortcode-bloginfo.php

Sitekit [sitekit_categories] Shortcode

The Sitekit Categories shortcode is a powerful tool that lists your website’s categories. It allows you to customize the order, display count, hierarchy, and more. This shortcode fetches and displays categories based on specified attributes. It can hide empty categories and sort them by name or count. It can also exclude certain categories.

Shortcode: [sitekit_categories]

Parameters

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

  • orderby – Determines the order of categories based on name or ID
  • order – Sets the direction of the order, ascending (ASC) or descending (DESC)
  • show_count – Decides whether to display the number of posts in each category
  • hide_empty – Decides whether to hide categories without posts
  • hierarchical – Determines whether child categories should be included
  • depth – Controls how many levels of the hierarchy of categories are included
  • taxonomy – Specifies the taxonomy to retrieve categories from
  • child_of – Retrieves categories that are children of the specified category
  • exclude – Excludes certain categories from the list
  • exclude_tree – Excludes a category and all its children
  • title_li – Sets the title for the list of categories
  • show_option_all – Shows an option to view all categories
  • show_option_none – Displays a message when no categories are available
  • feed – Adds a feed link to each category
  • echo – Decides whether to echo the list of categories or return it

Examples and Usage

Basic example – Display categories ordered by name in ascending order.

[sitekit_categories orderby="name" order="ASC"]

Advanced examples

Display categories ordered by count in descending order, excluding a specific category.

[sitekit_categories orderby="count" order="DESC" exclude="10"]

Show all categories including the ones without any posts, ordered by name in descending order.

[sitekit_categories orderby="name" order="DESC" hide_empty="0"]

Display categories in a hierarchical order, excluding a specific category tree.

[sitekit_categories hierarchical="1" exclude_tree="5"]

Show categories with a feed link, ordered by name in ascending order.

[sitekit_categories orderby="name" order="ASC" feed="RSS"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sitekit_categories', 'sitekit_shortcode_categories' );

Shortcode PHP function:

function sitekit_shortcode_categories( $atts ) {
	$defaults = array(
		'orderby' => 'name',
		'order' => 'ASC',
		'show_count' => 0,
		'hide_empty' => 1,
		'hierarchical' => 1,
		'depth' => 0,
		'taxonomy' => 'category',
		'child_of' => 0,
		'exclude' => '',
		'exclude_tree' => '',
		'title_li' => '',
		'show_option_all' => '',
		'show_option_none' => '',
		'feed' => '',
		'echo' => 0
	);
	$atts_obj = shortcode_atts( $defaults, $atts );
	
	$categories = wp_list_categories( $atts_obj );
	
	$categories = "\n".'<ul class="sitekit-categories">' . "\n" . $categories . "\n" . '</ul><!-- .sitekit-categories -->' . "\n";
	
	return $categories . SITEKIT_PLUGIN_POWERED;
}

Code file location:

sitekit/sitekit/inc/sitekit-shortcode-categories.php

Sitekit [sitekit_iframe] Shortcode

The Sitekit iframe shortcode is a flexible tool for embedding content. It allows users to customize the source URL, dimensions, scrolling, and frameborder of the iframe. The default values can be overridden by providing new parameters. It sanitizes the URL and excludes any attributes starting with “on”, enhancing security.

Shortcode: [sitekit_iframe]

Parameters

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

  • src – URL of the content to display in the iframe
  • width – width of the iframe, can be in pixels or percentage
  • height – height of the iframe in pixels
  • scrolling – allows or disallows scrolling in the iframe
  • frameborder – controls the appearance of the border around the iframe

Examples and Usage

Basic Example – Embeds a YouTube video using the default parameters.

[sitekit_iframe]

Advanced Examples

Embeds a Vimeo video by specifying the ‘src’ parameter and adjusting the height and width of the iframe.

[sitekit_iframe src="http://vimeo.com/123456789" width="800" height="600"]

Embeds a Google Maps location by specifying the ‘src’ parameter, adjusting the height and width of the iframe, and disabling scrolling.

[sitekit_iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3151.8354345096036!2d144.95373531533367!3d-37.817209979751795!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6ad642af0f11fd81%3A0x5045675218ce6e0!2sMelbourne%20VIC%2C%20Australia!5e0!3m2!1sen!2sus!4v1574224245000" width="800" height="600" scrolling="no"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'sitekit_iframe', 'sitekit_shortcode_iframe' );

Shortcode PHP function:

function sitekit_shortcode_iframe( $atts ) {
	$defaults = array(
		'src' => 'http://www.youtube.com/embed/4qsGTXLnmKs',
		'width' => '100%',
		'height' => '500',
		'scrolling' => 'yes',
		'frameborder' => '0'
	);

	foreach ( $defaults as $default => $value ) { // add defaults
		if ( ! @array_key_exists( $default, $atts ) ) { // mute warning with "@" when no params at all
			$atts[$default] = $value;
		}
	}

	$html = "\n".'<iframe';
	foreach( $atts as $attr => $value ) {
		// sanitize url
		if ( strtolower($attr) == 'src' ) {
			$value = esc_url( $value );
		}
		// remove all attributes starting with "on". Examples: onload, onmouseover, onfocus, onpageshow, onclick
		if ( strpos( strtolower( $attr ), 'on' ) !== 0 ) {
			if ( $value != '' ) {
				// adding all attributes
				$html .= ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"';
			} else {
				// adding empty attributes
				$html .= ' ' . esc_attr( $attr );
			}
		}
	}
	$html .= '></iframe>'."\n";

	return $html . SITEKIT_PLUGIN_POWERED;
}

Code file location:

sitekit/sitekit/inc/sitekit-shortcode-iframe.php

Sitekit [null] Shortcode

The Sitekit Posts shortcode is a powerful tool that fetches and displays posts based on specified parameters. The shortcode: [sitekit_posts] allows you to customize the post type, order, and other attributes. The PHP function ‘sitekit_shortcode_posts’ defines these parameters, such as post type, posts per page, and order. It then creates a new WP_Query object with these attributes. The function loops through the posts and generates an HTML structure, displaying each post’s title as a link. If no posts match the criteria, it displays an error message.

Shortcode: [null]

Parameters

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

  • post_type – Specifies the type of posts to display
  • posts_per_page – Defines the number of posts per page
  • paged – Controls the page number to display
  • post_status – Filters the posts by their publication status
  • ignore_sticky_posts – Skips over sticky posts if set to true
  • order – Sets the direction of the posts order
  • orderby – Determines the parameter to order the posts by

Examples and Usage

Basic example – Displays a list of the most recent posts on your site.

[sitekit_posts]

Advanced examples

Display a list of the most recent posts, but limit the number of posts to 5.

[sitekit_posts posts_per_page=5]

Display a list of posts, but order them in ascending order based on the post title.

[sitekit_posts order='ASC' orderby='title']

Display a list of posts from a specific post type, for example ‘product’.

[sitekit_posts post_type='product']

Display a list of posts, but exclude sticky posts.

[sitekit_posts ignore_sticky_posts=true]

These examples demonstrate the versatility of the ‘sitekit_posts’ shortcode and how it can be customized with different attributes to suit your specific needs.

PHP Function Code

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

Shortcode line:

add_shortcode( 'sitekit_posts', 'sitekit_shortcode_posts' );

Shortcode PHP function:

function sitekit_shortcode_posts( $atts ) {
	
	if ( get_query_var('paged') ) {
		$paged = get_query_var('paged');
	} elseif ( get_query_var('page') ) { // 'page' is used instead of 'paged' on Static Front Page
		$paged = get_query_var('page');
	} else {
		$paged = 1;
	}
	
	$defaults = array(
		'post_type' => 'post',
		'posts_per_page' => 100, //get_option('posts_per_page'),
		'paged' => $paged,
		'post_status' => 'publish',
		'ignore_sticky_posts' => true,
		//'cat' => 47,
		//'category_name' => 'custom-cat',
		'order' => 'DESC', // 'ASC'
		'orderby' => 'date' // modified | title | name | ID | rand
	);
	$atts_obj = shortcode_atts( $defaults, $atts );
	
	$custom_query = new WP_Query( $atts_obj );
	
	//print_r($atts);
	
	$posts_output = '';

	if ( $custom_query->have_posts() ) :
		$posts_output .= '<ul class="sitekit-posts">'."\n";
		while( $custom_query->have_posts() ) : $custom_query->the_post();
			$posts_output .= '<li>';
			$posts_output .= '<a href="'. get_permalink() .'">'. get_the_title(). '</a>';
			$posts_output .= '</li>'."\n";
		endwhile;
		$posts_output .= '</ul><!-- .sitekit-posts -->'."\n";
		if ($custom_query->max_num_pages > 1) : // custom pagination
			//$orig_query = $wp_query; // fix for pagination to work
			//$wp_query = $custom_query;
			/* ?>
			<nav class="prev-next-posts">
				<div class="prev-posts-link">
					<?php echo get_next_posts_link( 'Older Entries', $custom_query->max_num_pages ); ?>
				</div>
				<div class="next-posts-link">
					<?php echo get_previous_posts_link( 'Newer Entries' ); ?>
				</div>
			</nav>
			<?php */
			//$wp_query = $orig_query; // fix for pagination to work
		endif;
	 
		wp_reset_postdata(); // reset the query 
	else:
		$posts_output .= '<p>'.__('Sorry, no posts matched your criteria.', 'sitekit').'</p>';
	endif;
	
	return $posts_output . SITEKIT_PLUGIN_POWERED;
}

Code file location:

sitekit/sitekit/inc/sitekit-shortcode-posts.php

Conclusion

Now that you’ve learned how to embed the Sitekit 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 *