WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to use Page slugs as breadcrumbs? (2 posts)

  1. MattV
    Member
    Posted 3 years ago #

    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.)

  2. MattV
    Member
    Posted 3 years ago #

    Ok I solved the problem. Have a look here for the code if you´re interested: http://wordpress.stackexchange.com/questions/24804/slugs-as-breadcrumbs-for-pages/24997#24997

Topic Closed

This topic has been closed to new replies.

About this Topic