Simple WP Breadcrumbs Shortcode

function simple_wp_breadcrumb_func( $atts ) {
	
	$atts = shortcode_atts( array(
		'seperator' => '>',
    ), $atts );
	
	$output = '';
	$seperator = ' ' . $atts['seperator'] . ' ';

	function create_url( $text, $href ) {
		return '<a href="' . $href . '">' . $text . '</a>';
	}
	
	$output .= create_url( "Home", get_site_url() );
	$output .= $seperator . create_url( get_the_title( get_option( 'page_for_posts' ) ), get_permalink( get_option( 'page_for_posts' ) ) );
	$output .= $seperator . create_url( get_the_title(), get_permalink() );
	
	return $output;
	
}

add_shortcode( 'simple_wp_breadcrumb', 'simple_wp_breadcrumb_func' );

Newsletter Updates

Enter your email address below to subscribe to my newsletter

Leave a Reply

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