This should do it, I used output buffering with ob_start()
and ob_get_clean
:
<?php
/**
* Breadcrumbs based on theme's functions
*
* @author Nabil Kadimi <[email protected]>
* @link http://wordpress.stackexchange.com/a/242547/17187
*/
add_action( 'init', function() {
add_shortcode( 'mycrumbs', function() {
/**
* Start capturing output.
*/
ob_start();
?>
<div class="x-breadcrumb-wrap">
<div class="x-container max width">
<?php x_breadcrumbs(); ?>
<?php if ( is_single() || x_is_portfolio_item() ) : ?>
<?php x_entry_navigation(); ?>
<?php endif; ?>
</div>
</div>
<?
/**
* Stop capturing output and return what was captured to WordPress.
*/
return ob_get_clean();
} ); // add_shortcode( 'mycrumbs', closure );
} ); // add_action( 'init', closure );