How to display related post by categories with next post of current post (don't latest post or random post) - thumbnails

How to display related post by categories with next post of current post (don't latest post or random post). I'm use code related post for twentytwelve theme. but now, author in wentytwelve_entry_meta() is repeat.
pls help me :
<div id="related_posts">
<?php
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach((get_the_category()) as $category) {
$id = $category->cat_ID;
}
global $wpdb;
$query = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON
($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON
($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->posts.post_status = 'publish'
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id = $category_ids[0]
AND $wpdb->posts.id < $post->ID
ORDER BY id DESC limit 3
";
$my_query = $wpdb->get_results($query);
if( $my_query) {
echo '<h3>Related Posts</h3><ul>';
foreach($my_query as $key => $post) {
?>
<li>
<div class="entry-header">
<div class="header-l">
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<p class="datetime">
<?php twentytwelve_entry_meta(); ?>
</p>
</div>
<?php the_post_thumbnail(); ?>
</div>
<div class="entry-summary">
<?php
$str_content = wp_trim_words($post->post_content);
$str_content = str_replace('[', '<', $str_content);
$str_content = str_replace(']', '>', $str_content);
echo $str_content;
?>
</div>
</li>
<?php
}
echo '</ul>';
}
}?>

WordPress customary is to use WP_Query class to fetch posts from DB, if you can modify your code to use WP_Query it would be easier.
WP_Query Reference
As you are using Custom Query to load your posts from DB, template tags like the_permalink(), the_title_attribute(), the_title() etc will not work properly that is the reason while theme function twentytwelve_entry_meta() fails.
As per codex reference Displaying Posts Using a Custom Select Query
You should try something like this:
global $wpdb;
$query = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON
($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON
($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->posts.post_status = 'publish'
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id = $category_ids[0]
AND $wpdb->posts.id < $post->ID
ORDER BY id DESC limit 3";
$my_query = $wpdb->get_results($query);
if($my_query) {
global $post;
echo '<h3>Related Posts</h3><ul>';
foreach($my_query as $key => $post) {
//use setup postdata, it works only for variable named $post.
setup_postdata($post);
//you can safely use template tags now.
?>
<li>
<div class="entry-header">
<div class="header-l">
<h1 class="entry-title">
<?php the_title(); ?>
</h1>
<p class="datetime">
<?php twentytwelve_entry_meta(); ?>
</p>
</div>
<?php the_post_thumbnail(); ?>
</div>
<div class="entry-summary">
<?php
$str_content = wp_trim_words($post->post_content);
$str_content = str_replace('[', '<', $str_content);
$str_content = str_replace(']', '>', $str_content);
echo $str_content;
?>
</div>
</li>
<?php
}
}
Other interesting post:
What does setup_postdata ($post ) do?

Related

Showing custom fields of custom post type in a date ordered list on a page

I'm struggling with this. I add multiple custom field values: in this case event dates with their title and location to all my projects (custom post type) and want to display them in a table together on a page called Calendar. I tried to query the posts but then the custom fields will show as groups together, and not as a date ordered list.
The event titles match the post title in this case.
My question is: what would be the best solution? Creating all the event dates as custom fields within the posts and then show them all together on a single page called calendar, or create them all in a calendar page and then filter those on title to show only the relevant ones in a single post that match the page title?
The event name is taken from a post object, which seemed the best solution for the scenario where all events are created on the same page, but other wise I might use just the post title.
Hope there is someone to help!
My code for the calendar (the part with upcoming dates):
<div class="Rtable upcoming Rtable--collapse">
<?php $outs = array(); if( have_rows('events') ): ?>
<?php while ( have_rows('events') ) : the_row(); ob_start();
// Get sub field values.
$date = get_sub_field('date');
$location = get_sub_field('location');
$website = get_sub_field('website');
$title = get_sub_field('title');
$premiere = get_sub_field('premiere');
$event = get_sub_field('date', false, false);
$today = strtotime(date('Ymd'));
$upcoming = strtotime($event);
$datefin = new DateTime($event); ?>
<?php if ($upcoming >=$today): ?>
<div class="Rtable-cell Rtable-cell--head <?php if( get_sub_field('premiere') == 'yes' ): ?>premiere <?php endif; ?>">
<?php if( get_sub_field('date') ): ?><?php the_sub_field('date'); ?><?php endif; ?>
</div>
<div class="Rtable-cell table-project-title"><?php if( get_sub_field('premiere') == 'yes' ): ?><span style="color: var(--magenta);">premiere:</span> <?php endif; ?>
<?php if( $title ): ?><?php foreach( $title as $post ):
// Setup this post for WP functions (variable must be named $post).
setup_postdata($post); ?><?php the_title(); ?> <?php endforeach; ?> <?php
// Reset the global post object so that the rest of the page works correctly.
wp_reset_postdata(); ?> <?php endif; ?>
</div>
<div class="Rtable-cell"><?php if( get_sub_field('location') ): ?><?php the_sub_field('location'); ?><?php endif; ?></div>
<div class="Rtable-cell Rtable-cell--foot"><?php if( get_sub_field('website') ): ?><a class="button" href="<?php echo esc_url( $website ); ?>" target="_blank">Tickets</a> <?php endif; ?></div>
<?php endif; ?>
<?php $outs[] = ob_get_clean(); endwhile; ?>
<?php
else :
endif;
$outs = array_reverse($outs);
echo implode($outs);
?>
</div><!-- UPCOMING END -->
I found the solution, to query by the custom field date. Result here:
<?php
/**
* Template Name: Calendar
*/
get_header();
?>
<?php get_header();
?>
<div class="content-header yellow">
<h1><?php the_title();
?></h1>
</div>
<!-- Kalender -->
<div class="yellow content">
<div class="Rtable upcoming Rtable--collapse">
<?php
// Create an empty array for storage
$post_data = array();
// Set arguments for your query
$args = array(
'post_type' => 'projects',
'posts_per_page' => -1
);
// Do our query with any arguments from above
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// Setup our repeater
if ( have_rows( 'events' ) ):
while ( have_rows( 'events' ) ) : the_row();
// Optional - Only get posts that match a true false within our repeater
$event = get_sub_field( 'date', false, false );
$today = strtotime( date( 'Ymd' ) );
$upcoming = strtotime( $event );
$datefin = new DateTime( $event );
if ( $upcoming >= $today ) {
// Build our array with the data we need using key => value
$post_data[] = array(
'url' => get_the_permalink(),
'title' => get_the_title(),
'date' => get_sub_field( 'date' ),
'location' => get_sub_field( 'location' ),
'website' => get_sub_field( 'website' ),
);
}
endwhile;
endif;
}
} ?>
<?php // Custom function to use in our sort to list the items by date
function subval_sort( $a, $b ) {
if ( $a['date'] == $b['date'] )
return 0;
return $a['date'] < $b['date'] ? -1 : 1;
}
// Sort our multidimensional array by sub array value
usort( $post_data, 'subval_sort' );
// We can now work our data normally through easy to access methods
foreach ( $post_data as $post ) {
?>
<div class="Rtable-cell Rtable-cell--head <?php if( get_sub_field('premiere') == 'yes' ): ?>premiere <?php endif; ?>">
<?php $format_in = 'm/d/Y';
// the format your value is saved in ( set in the field options )
$format_out = 'd/m/Y';
// the format you want to end up with
$date = DateTime::createFromFormat( $format_in, $post['date'] );
echo $date->format( $format_out ) . ' ' ;
?>
</div>
<div class="Rtable-cell table-project-title"><?php if ( get_sub_field( 'premiere' ) == 'yes' ): ?><span style="color: var(--magenta);">premiere:</span> <?php endif;
?>
<a href="<?php echo $post['url']; ?> ">
<?php
echo $post['title'] . ' ' ;
?>
</a>
</div>
<div class="Rtable-cell">
<?php echo $post['location'] . ' ' ;
?>
</div>
<div class="Rtable-cell Rtable-cell--foot">
<a class="button" href="<?php
echo $post['website']; ?> ">
tickets
</a>
</div>
<?php }
?>
</div>
</div>
<?php get_footer();
?>

How to get category discription?

This is phtml code for getting selected category. I want to get category description. How can I get that?
<?php
$catId =2;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$subcategory = $objectManager->create('Magento\Catalog\Model\Category')->load($catId);
$subcats = $subcategory->getChildrenCategories();
?>
<ul>
<li> <span> All Categories </span> </li>
<?php
foreach ($subcats as $subcat) {
if ($subcat->getIsActive()) {
$subcat_url = $subcat->getUrl();
$subcat_img = "";
$placeholder_img = "/media/placeholder.png";
?>
<li>
<a href="<?php echo $subcat_url; ?>">
<?php echo $subcat->getName(); ?>
</a>
</li>
<?php
}
}
?>
</ul>
To get the Category Description, you have to load Category and after that, you can use getDescription() function.
I have made some changes in your code. Please find the new code here:
<?php
$catId =2;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$subcategory = $objectManager->create('Magento\Catalog\Model\Category')->load($catId);
$subcats = $subcategory->getChildrenCategories();
?>
<ul>
<li> <span> All Categories </span> </li>
<?php
foreach ($subcats as $subcat) {
if ($subcat->getIsActive()) {
$subcat = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
$subcat_url = $subcat->getUrl();
$subcat_img = "";
$placeholder_img = "/media/placeholder.png";
?>
<li>
<a href="<?php echo $subcat_url; ?>">
<?php echo $subcat->getName(); ?>
</a>
<p><?php echo $subcat->getDescription(); ?></p>
</li>
<?php
}
}
?>
</ul>
Note: In Magento 2, the direct use of ObjectManager in template files is not a good practice. Dependency injection is the recommended approach.
For more details on how to use ObjectManager and what the consequences are of using the ObjectManager directly, you can follow the link below:
https://magento.stackexchange.com/questions/117098/magento-2-to-use-or-not-to-use-the-objectmanager-directly

wp shortcode breaks get_post_thumbnail

I'm having some trouble with short code's breaking a featured image I have set on my home page in Wordpress (4.0). For some reason, when I paste in my shortcode in the wp-admin > page > edit > content for the home page, suddenly my featured image stops working. It's working until I paste in the shortcode and update the page, but then the image disappears and the_post_thumbnail() returns false. I've also tried get_the_post_thumbnail() without success.
Here's my code excerpt from "front-page.php":
<div class="small-12 medium-6 columns">
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; ?>
</div>
<div class="small-12 medium-6 columns">
<?php if (has_post_thumbnail()) {the_post_thumbnail();} ?>
</div>
And here's the shortcode function from "functions.php":
// [random_testimonial]
function short_code_get_random_testimonial(){
$args = array( 'post_type' => 'testimonial', 'posts_per_page' => 1, 'orderby' => 'rand' );
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
$random_testimonial = get_the_content();
$author = get_the_title();
$rt = '<p class="quote">' . $random_testimonial;
$rt .= '</p><p class="right">– ' . $author . '</p>';
endwhile;
return $rt;
}
// Register the shortcodes.
add_shortcode( 'random_testimonial', 'short_code_get_random_testimonial' );
// Allow text widgets to contain shortcodes.
add_filter('widget_text', 'do_shortcode');
add_filter('the_content', 'do_shortcode');
Any ideas would be greatly appreciated.
I think I may have solved this one. It seems to have something to do with the fact that I was calling a custom post type with the shortcode, so by the time the_post_thumbnail() was called, the query had changed to refer to the custom post type included in the shortcode ("testimonial") rather than the parent post (in this case the home page). I revised my code as follows to catch the image before the shortcode is called, and all is working again:
<div class="small-12 medium-6 columns">
<?php while ( have_posts() ) : the_post(); ?>
<?php
// go ahead and get the post image in case [random_testimonial]
// shortcode is used in page content which will break the query.
if (has_post_thumbnail()) {$image = get_the_post_thumbnail();} ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; ?>
</div>
<div class="small-12 medium-6 columns">
<?php
// Echo post image from above.
if(isset($image)){echo $image;}
?>
</div>

facebook status on web with picture

Finally i got this done with the likes and statuses but I would like to ask for help if it is possible somehow to transfer also the pictures on web.
thank you
<?php
$facebook_page_id = '**********';
$access_token = '************';
$number_of_posts = 2;
$json_content = file_get_contents('http://graph.facebook.com/'.$facebook_page_id.'/feed?access_token='.$access_token);
$raw_data = json_decode($json_content);
$i=0;
foreach ($raw_data->data as $feed ) {
$feed_id = explode("_", $feed->id);
if (!empty($feed->message)) {
$i++;
if ($i<($number_of_posts+1)) {
?>
<div class=”fb_update”>
<?php if (!empty($feed->likes->count)) { ?>
<div class=”fb_likes”>
<?php echo $feed->likes->count; ?>
</div>
<?php } ?>
<?php if (!empty($feed->created_time)) { ?>
<div class=”fb_date”>
<?php echo date('F j, Y', strtotime($feed->created_time)); ?>
</div>
<?php } ?>
<div class=”fb_message”>
<?php echo $feed->message; ?>
</div>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
Yes, $feed->picture will get you the URL to an image for a particular item, if it exists.
You should really look at using cURL via the PHP SDK for this instead of file_get_contents(). It is more robust.

Creating child CMS pages in Magento

I would like to create a subordinate set of CMS pages in Magento so that the breadcrumb navigation at the top of the page looks like this:
Home > Parent CMS Page > Child CMS Page
Even though I can specify a hierarchical relationship with the URL key field, it seems to be that all CMS pages in Magento are listed in the root directory by default:
Home > Child CMS Page
Any ideas?
You are right, there is no hierarchy of CMS pages in Magento. The best solution would be to create a real hierarchy by adding a parent_id to CMS pages and modifying the CMS module to handle nested URLs and breadcrumbs. But that requires a lot of coding.
A quick-and-dirty hack is to modify the breadcrumbs manually on each subpage by adding something like this to the layout update XML:
<reference name="root">
<action method="unsetChild"><alias>breadcrumbs</alias></action>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs">
<action method="addCrumb">
<crumbName>home</crumbName>
<crumbInfo><label>Home page</label><title>Home page</title><link>/</link></crumbInfo>
</action>
<action method="addCrumb">
<crumbName>myparentpage</crumbName>
<crumbInfo><label>My Parent Page</label><title>My Parent Page</title><link>/myparentpage/</link></crumbInfo>
</action>
<action method="addCrumb">
<crumbName>mysubpage</crumbName>
<crumbInfo><label>My Sub Page</label><title>My Sub Page</title></crumbInfo>
</action>
</block>
</reference>
I had the same problem with breadcrumbs and cms pages a few days ago check here ->
Similar to Anders Rasmussen post I edited every cms page manually
In breadcrumbs.phtml I added a little condition to define if a Page is a CMS page (thanks to Alan Storm) and remove standard crumb(s) and added new crumbs via xmllayout.
<?php
if($this->getRequest()->getModuleName() == 'cms'){
unset($crumbs['cms_page']);
}
?>
xml:
<reference name="breadcrumbs">
<action method="addCrumb">
<crumbName>cms_page_1st_child</crumbName>
<crumbInfo><label>1st child</label><title>1st child</title><link>/1st child/</link></crumbInfo>
</action>
<action method="addCrumb">
<crumbName>cms_page_2nd_child</crumbName>
<crumbInfo><label>2nd child</label><title>2nd child</title></crumbInfo>
</action>
</reference>
hope that helps,
Rito
For enterprise (version 1.12) use this code at following file, location is:
default->template->page->html->breadcrumb.phtml.
<?php
$cms_id = Mage::getSingleton('cms/page')->getPageId();
if($cms_id):
if($_SERVER['REQUEST_URI']) {
$trim_data = substr($_SERVER['REQUEST_URI'],1);
$data = explode('/',$trim_data);
}
$cms_collection = array();
$url_full = '';
$cms_enterprise = '';
foreach($data as $identifier) {
$page_data = Mage::getModel('cms/page')->getCollection()
->addFieldToFilter('identifier', $identifier);
if($page_data) {
foreach($page_data as $single) {
if($single->getContentHeading() != null) {
if($single->getPageId()) {
$cms_enterprise = Mage::getModel('enterprise_cms/hierarchy_node')->getCollection()
->addFieldToFilter('page_id', $single->getPageId());
foreach($cms_enterprise as $single_enterprise) {
$url_full = $single_enterprise->getRequestUrl();
}
}
$cms_collection[] = array($single->getTitle(), $single->getContentHeading(), $url_full );
} else {
if($single->getPageId()) {
$cms_enterprise = Mage::getModel('enterprise_cms/hierarchy_node')->getCollection()
->addFieldToFilter('page_id', $single->getPageId());
foreach($cms_enterprise as $single_enterprise) {
$url_full = $single_enterprise->getRequestUrl();
}
}
$cms_collection[] = array($single->getTitle(), $single->getTitle(), $url_full );
}
}
}
}
$count = count($cms_collection);
$i = 1;
?>
<?php if(count($cms_collection)): ?>
<div class="breadcrumbs">
<ul>
<li>
<a href="<?php echo $this->getUrl() /*Home*/ ?>" title="<?php echo $this->__('Home'); /*Home Title*/ ?>">
<?php echo $this->__('Home'); /*Home Name*/ ?>
</a>
<span>> </span>
</li>
<?php foreach($cms_collection as $key=>$value): ?>
<?php if($i == $count): ?>
<li>
<strong>
<?php echo $value[1]; /*Name*/ ?>
</strong>
</li>
<?php else: ?>
<li>
<a href="<?php echo $this->getUrl().$value[2] /*Identifier*/ ?>" title="<?php echo $value[0] /*Title*/ ?>">
<?php echo $value[1]; /*Name*/ ?>
</a>
<span>> </span>
</li>
<?php endif; ?>
<?php $i++; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php else: ?>
<?php if($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul>
<?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?>
<li class="<?php echo $_crumbName ?>">
<?php if($_crumbInfo['link']): ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php elseif($_crumbInfo['last']): ?>
<strong><?php echo $this->htmlEscape($_crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $this->htmlEscape($_crumbInfo['label']) ?>
<?php endif; ?>
<?php if(!$_crumbInfo['last']): ?>
<span>> </span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
Thanks,
Kashif
This is my solution of the problem. I use custom layout for most of the CMS pages (default/template/page/cmsLayout.phtml) so I heve added following code into the layout file:
<div class="col-main">
<?php
$urlPart=str_replace(Mage::getUrl(),'',Mage::getUrl('', array('_current' => true,'_use_rewrite' => true)));
$urlPart=explode('/',$urlPart);
$string='';
$return='<div class="breadcrumbs"><ul><li class="home">Home<span> / </span></li>';
$count=count($urlPart);
foreach($urlPart as $value)
{
$count--;
$string.='/'.$value;
$string=trim($string, '/');
$pageTitle = Mage::getModel('cms/page')->load($string, 'identifier')->getTitle();
if($count==0)
$return.='<li><strong>'.$pageTitle.'</strong></li>';
else
$return.='<li>'.$pageTitle.'<span> / </span></li>';
}
echo $return.'</li></ul></div>';
?>
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
update
-oops- this might be an enterprise feature only
There is a built-in CMS page hierarchy option in Magento.
To turn it on:
System > Configuration > General > Content Management > CMS Page Hierarchy - see here
To organise the hierarchy tree:
CMS > Pages > Manage Hierarchy
To manage the position of a page in the tree, after saving a page, go to its "hierarchy tab" - see the screenshot:
In the example the page "Our culture" is a child of "jobs" and not of the root directory
For Magento Enterprise, I have created an extension to solve this. It uses the built in CMS Hierarchy in the backend. The module is called Demac/BananaBread and shouldn't require any hacks or customization.
Direct download: here
Link to article: http://www.demacmedia.com/magento-commerce/introducing-demac_bananabread-adding-cms-breadcrumbs-from-the-hierarchy-in-magento/
I built a custom block as to generate the crumbs (removing the built-in and replacing with the custom one below in the layout):
namespace Uprated\Theme\Block\Html;
class UpratedBreadcrumbs extends \Magento\Framework\View\Element\Template
{
/**
* Current template name
*
* #var string
*/
public $crumbs;
protected $_template = 'html/breadcrumbs.phtml';
protected $_urlInterface;
protected $_objectManager;
protected $_repo;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\UrlInterface $urlInterface,
\Magento\Framework\ObjectManagerInterface $objectManager,
array $data = [])
{
$this->_urlInterface = $urlInterface;
$this->_objectManager = $objectManager;
$this->_repo = $this->_objectManager->get('Magento\Cms\Model\PageRepository');
$this->getCrumbs();
parent::__construct($context, $data);
}
public function getCrumbs() {
$baseUrl = $this->_urlInterface->getBaseUrl();
$fullUrl = $this->_urlInterface->getCurrentUrl();
$urlPart = explode('/', str_replace($baseUrl, '', trim($fullUrl, '/')));
//Add in the homepage
$this->crumbs = [
'home' => [
'link' => $baseUrl,
'title' => 'Go to Home Page',
'label' => 'Home',
'last' => ($baseUrl == $fullUrl)
]
];
$path = '';
$numParts = count($urlPart);
$partNum = 1;
foreach($urlPart as $value)
{
//Set the relative path
$path = ($path) ? $path . '/' . $value : $value;
//Get the page
$page = $this->getPageByIdentifier($path);
if($page) {
$this->crumbs[$value] = [
'link' => ($partNum == $numParts) ? false : $baseUrl . $path,
'title' => $page['title'],
'label' => $page['title'],
'last' => ($partNum == $numParts)
];
}
$partNum++;
}
}
protected function getPageByIdentifier($identifier) {
//create the filter
$filter = $this->_objectManager->create('Magento\Framework\Api\Filter');
$filter->setData('field','identifier');
$filter->setData('condition_type','eq');
$filter->setData('value',$identifier);
//add the filter(s) to a group
$filter_group = $this->_objectManager->create('Magento\Framework\Api\Search\FilterGroup');
$filter_group->setData('filters', [$filter]);
//add the group(s) to the search criteria object
$search_criteria = $this->_objectManager->create('Magento\Framework\Api\SearchCriteriaInterface');
$search_criteria->setFilterGroups([$filter_group]);
$pages = $this->_repo->getList($search_criteria);
$pages = ($pages) ? $pages->getItems() : false;
return ($pages && is_array($pages)) ? $pages[0] : [];
}
Then used a slightly modified .phtml template to display them:
<?php if ($block->crumbs && is_array($block->crumbs)) : ?>
<div class="breadcrumbs">
<ul class="items">
<?php foreach ($block->crumbs as $crumbName => $crumbInfo) : ?>
<li class="item <?php /* #escapeNotVerified */ echo $crumbName ?>">
<?php if ($crumbInfo['link']) : ?>
<a href="<?php /* #escapeNotVerified */ echo $crumbInfo['link'] ?>" title="<?php echo $block->escapeHtml($crumbInfo['title']) ?>">
<?php echo $block->escapeHtml($crumbInfo['label']) ?>
</a>
<?php elseif ($crumbInfo['last']) : ?>
<strong><?php echo $block->escapeHtml($crumbInfo['label']) ?></strong>
<?php else: ?>
<?php echo $block->escapeHtml($crumbInfo['label']) ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
Working fine for me in 2.1