Skip to content

Instantly share code, notes, and snippets.

@wpflames
Created March 16, 2022 16:44
Show Gist options
  • Select an option

  • Save wpflames/29d3e6698433bc24277f38eb3b9d4598 to your computer and use it in GitHub Desktop.

Select an option

Save wpflames/29d3e6698433bc24277f38eb3b9d4598 to your computer and use it in GitHub Desktop.
Display Breadcrumbs without Plugin in WordPress
<?php
$theParent = wp_get_post_parent_id(get_the_ID());
if ($theParent) { ?>
<div class="wrap">
<div class="breadcrumbs">
<p>
<a href="<?php echo site_url(); ?>">
<svg id="icon-home" width="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512">
<path d="M511.8 287.6L512.5 447.7C512.5 450.5 512.3 453.1 512 455.8V472C512 494.1 494.1 512 472 512H456C454.9 512 453.8 511.1 452.7 511.9C451.3 511.1 449.9 512 448.5 512H392C369.9 512 352 494.1 352 472V384C352 366.3 337.7 352 320 352H256C238.3 352 224 366.3 224 384V472C224 494.1 206.1 512 184 512H128.1C126.6 512 125.1 511.9 123.6 511.8C122.4 511.9 121.2 512 120 512H104C81.91 512 64 494.1 64 472V360C64 359.1 64.03 358.1 64.09 357.2V287.6H32.05C14.02 287.6 0 273.5 0 255.5C0 246.5 3.004 238.5 10.01 231.5L266.4 8.016C273.4 1.002 281.4 0 288.4 0C295.4 0 303.4 2.004 309.5 7.014L416 100.7V64C416 46.33 430.3 32 448 32H480C497.7 32 512 46.33 512 64V185L564.8 231.5C572.8 238.5 576.9 246.5 575.8 255.5C575.8 273.5 560.8 287.6 543.8 287.6L511.8 287.6z"/>
</svg>
</a>
<svg id="chevron" width="8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24.259 39.975">
<path fill="black" d="M51.11,59.2,33.32,76.989a2.2,2.2,0,0,1-3.107,0l-2.075-2.075a2.2,2.2,0,0,1,0-3.1l14.1-14.166-14.1-14.166a2.2,2.2,0,0,1,0-3.1L30.213,38.3a2.2,2.2,0,0,1,3.107,0l17.79,17.79A2.2,2.2,0,0,1,51.11,59.2Z" transform="translate(-27.494 -37.657)" fill="#fff"/>
</svg>
<a class="parent-link" href="<?php echo get_permalink($theParent); ?>">
<?php echo get_the_title($theParent); ?>
</a>
<span class="current_page">
<?php the_title(); ?>
</span>
</p>
</div>
</div>
<?php }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment