Support » How-To and Troubleshooting » [Resolved] How to use Page slugs as breadcrumbs?

[Resolved] How to use Page slugs as breadcrumbs?

  • I´m trying to create a function that creates a breadcrumb trail of Page slugs, showing the path from “home” to the current (sub)page.

    For example, on the page “example.com/attractions/parcs/parc-name” this breadcrumb would show up: Home > Attractions > Parcs > Parc Name

    I already have a working function that shows a breadcrumb trail with page titles. I´m looking to replace the page title output with the page slugs.

    Here´s the breadcrumb function:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Also, the following code snippets might help:

    • Get the post slug outside of The Loop: global $post; echo $post->post_name;
    • Get posts´parent slug <?php global $post; if($post->post_parent) { $post_data = get_post($post->post_parent); echo $post_data->post_name; } ?>

    I´m really stuck here, so all help is welcome!!

    (Note: I´ve posted this question on WP Stackexchange 6 hours ago, but haven´t received any replies. I´ll monitor both threads and if a solution is posted I´ll duplicate it inmeidately to the other thread.)

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] How to use Page slugs as breadcrumbs?’ is closed to new replies.
Skip to toolbar