Flexy Breadcrumb Shortcode

Below, you’ll find a detailed guide on how to add the Flexy Breadcrumb Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Flexy Breadcrumb Plugin shortcode not to show or not to work correctly.

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

Plugin Icon
Flexy Breadcrumb

"Flexy Breadcrumb is a user-friendly WordPress plugin that enhances website navigation by providing a customizable and interactive breadcrumb trail. It's perfect for improving user experience."

★★★★☆ (19) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [flexy_breadcrumb]

Flexy Breadcrumb [flexy_breadcrumb] Shortcode

The Flexy Breadcrumb shortcode allows you to display a breadcrumb navigation on your WordPress site. It dynamically generates the breadcrumb trail based on the current page, post, or category. This shortcode supports various pages such as WooCommerce Shop Page, Custom Post Type Listing, Archive Pages, Tag Page, and more. It also supports different archive pages like daily, monthly, and yearly archives.

Shortcode: [flexy_breadcrumb]

Examples and Usage

Basic example – Show the breadcrumb trail on your page.

[flexy_breadcrumb]

PHP Function Code

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

Shortcode line:

add_shortcode( 'flexy_breadcrumb', array( $this, 'flexy_breadcrumb_shortcode' ) );

Shortcode PHP function:

function flexy_breadcrumb_shortcode( $atts, $content = NULL ) {
		
		ob_start();
		global $post, $shortcode_args;

		// Shortcode Default Array
		$shortcode_args = array(
			'before' => '<p>',
			'after' => '</p>',
		);

		// Combines user shortcode attributes with known attributes
		$shortcode_args = shortcode_atts( apply_filters( 'fbc_template_params', $shortcode_args, $atts ), $atts );

		// Display breadcrumb other than front page
		if ( !is_front_page() ) {
			?>
			<!-- Flexy Breadcrumb -->
			<div class="fbc fbc-page">

				<!-- Breadcrumb wrapper -->
				<div class="fbc-wrap">

					<!-- Ordered list-->
					<ol class="fbc-items" itemscope itemtype="<?php echo esc_url( "https://schema.org/BreadcrumbList" ); ?>">
						<?php
						// Breadcrumb Trail Class Object
						$fbcObj = new Flexy_Breadcrumb_Trail();
						$fbcObj->before_wrap = $shortcode_args['before'];
						$fbcObj->after_wrap = $shortcode_args['after'];

						// Home text & icon
						$fbcObj->fbc_home_template();

						// For Posts Page
						$post_page_title = get_the_title( get_option( 'page_for_posts', true ) );

						
						// For WooCommerce Shop Page
						if ( class_exists( 'WooCommerce' ) && is_shop() ) {
							global $post;
							$page_id = wc_get_page_id( 'shop' );
							$post = get_post( $page_id );
							$fbcObj->fbc_page_trail();
						} elseif /* For Page and its Child Pages */ ( is_page() ) {
							$fbcObj->fbc_page_trail();
						} elseif /* For Custom Post Type Listing or Category Pages */ ( is_tax() && !is_category() && !is_tag() ) {
							$fbcObj->fbc_cpt_terms_trail();
						} elseif /* For Post Type Archive Pages */ ( is_archive() && !is_tax() && !is_category() && !is_tag() && !is_month() && !is_year() && !is_day() && !is_author() ) {
							$fbcObj->fbc_post_archive_trail();
						} elseif /* For Post Type Detail Page */ ( is_single() ) {
							$fbcObj->fbc_post_detail_trail();
						} elseif /* For Default Post Categories, Tags, Parent Categories and Child Categories */ ( is_category() ) {
							$fbcObj->fbc_category_trail();
						} elseif /* For Tag Page */ ( is_tag() ) {
							$fbcObj->fbc_tag_trail();
						} elseif /* For Day Archive Page */ ( is_day() ) {
							$fbcObj->fbc_day_archive_trail();
						} else if /* For Monthly Archive Page */ ( is_month() ) {
							$fbcObj->fbc_monthly_archive_trail();
						} elseif /* For Day Yearly Page */ ( is_year() ) {
							$fbcObj->fbc_yearly_archive_trail();
						} elseif /* For Author Page */ ( is_author() ) {
							$fbcObj->fbc_author_page_trail();
						} elseif /* For Search Page */ ( is_search() ) {
							$fbcObj->fbc_search_page_trail();
						} elseif /* For 404 Page */ ( is_404() ) {
							$fbcObj->fbc_404();
						} elseif /* For Posts Page */ ( NULL !== $post_page_title ) {
							$fbcObj->fbc_page_post_trail();
						}
						?>
					</ol>
					<div class="clearfix"></div>
				</div>
			</div>
			<?php
		}
		$html = ob_get_clean();
		return apply_filters('sep_fb_event_listing_shortcode', $html . do_shortcode($content));
	}

Code file location:

flexy-breadcrumb/flexy-breadcrumb/includes/class-flexy-breadcrumb-shortcode.php

Conclusion

Now that you’ve learned how to embed the Flexy Breadcrumb Plugin shortcode, 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 *