Book a Free Call

Check if WP page has parent and link back to it (breadcrumb)



Here’s a quick home-made breadcrumb for WordPress in case you aren’t using the built-in Yoast one or whatever. Add this to your template:

<?php 
$parent = wp_get_post_parent_id(get_the_ID());
if ( $parent ) {
echo '<nav aria-label="breadcrumb"><a href="'.get_permalink( $parent ).'" class="backto"><span>◀</span> Back to '.get_the_title($parent).'</a></nav>';
}
?>

Need rapid website development:

For smaller projects at high speed


  • Adding script tag embed to Gatsby component

    Read More
  • Get more than 100 queries in GraphQL (I felt stupid)

    Read More
  • Animate on Scroll (AOS) into Nuxt js

    Read More
  • WordPress Super-admin hack

    Read More
  • Add content or ACF field under thumbnail/image gallery in Woocommerce

    Read More

Tags


Categories

Is it urgent? Donate to Cork Simon

Got an urgent issue?

Charlie's Cottage, Carrigrohane, Co. Cork, T12 WY9H

(085) 7686677