Forum
Starting `perch_item_index` at 2
Hi all
I was just wondering if there's a way of starting perch_item_index
at 2 instead of the default 1?
I'm trying to create a breadcrumb trail using Schema markup with 'Home' as position 1, so need the first item in the 'loop' to have a position of 2.
<perch:before>
<div class="container">
<ol class="breadcrumbs" itemscope itemtype="https://schema.org/BreadcrumbList">
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><span itemprop="name">Home</span><meta itemprop="position" content="1" /></li>
</perch:before>
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><span itemprop="name"><perch:pages id="pageNavText" /></span><meta itemprop="position" content="<perch:pages id="perch_item_index" />" /></li>
<perch:after>
</ol>
</div>
</perch:after>
Many thanks
Hi Glen,
The best way I can think of is to skip the template and loop through each item, adding +1 to a
$num
variable so on your page the code would be:I would create a template filter to add whatever value you want to the index.
https://docs.grabaperch.com/api/template-filters/