Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6757081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:36:13+00:00 2026-05-26T13:36:13+00:00

I created/modified a function to display breadcrumbs on pages on WordPress. The modified version

  • 0

I created/modified a function to display breadcrumbs on pages on WordPress. The modified version makes use of #post->post_parent to get the parent of a page in order to have a full breadcrumb trail (home > page 1 > page 2 > page 3 vs. home > page 3)

The code executes perfectly on page (ie. home > page 1 > page 2 > page 3). But when I place it into a function and call it form the functions.php page it cannot detect if the page has a parent using $post->post_parent (ie. page 3 vs. home > page 3).

Could this be because the on page code is executed in the_loop but the function is somehow outside of it?

On page code:

if (!is_home()) {
            echo "<ul id='breadcrumb'>";
            echo '<li><a href="';
            echo get_option('home');
            echo '">HOME';
            echo "</a></li>";
            if (is_category() || is_single()) {
                the_category('title_li=');
                if (is_single()) {
                    the_title('<li>', '</li>');
                    echo "</ul>";
                }
            } elseif (is_page()) {
                if(!$post->post_parent){
                    //echo "No Parent";
                    }
                else{

                    echo '<li>'.  wp_list_pages('include='.$post->post_parent.'&title_li=' ).'</li>';
                }


                the_title('<li>', '</li>');
                echo "</ul>";
            }
        }

Function code:

function the_breadcrumb() {
        if (!is_home()) {
            echo "<ul id='breadcrumb'>";
            echo '<li><a href="';
            echo get_option('home');
            echo '">HOME';
            echo "</a></li>";
            if (is_category() || is_single()) {
                the_category('title_li=');
                if (is_single()) {
                    the_title('<li>', '</li>');
                    echo "</ul>";
                }
            } elseif (is_page()) {
                if(!$post->post_parent){
                    //echo "No Parent";
                    }
                else{

                    echo '<li>'.  wp_list_pages('include='.$post->post_parent.'&title_li=' ).'</li>';
                }


                the_title('<li>', '</li>');
                echo "</ul>";
            }
        }
    }

There is nothing inherently different about this code except that it is now wrapped in a function. The fact that it doesn’t display the parent pages is frustrating. I don’t want to have to include this code on every page template I create.

Help & Suggestions will be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:36:14+00:00Added an answer on May 26, 2026 at 1:36 pm

    $post ist not defined in your function. Try to give $post as parameter to the function:

    function the_breadcrumb($post) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a site using wordpress. I installed the 'starkers' theme and modified it.
In this code I created a function called someFunction. Then I modified Function.prototype.apply and
I created a CoreData application using the Cocoa Touch Template. I modified the included
How do you implement a last-modified column in SQL? I know for a date-created
A DB Audit Trail captures the User Last Modified, Modified Date, and Created Date.
I created a single page (with code behind .vb) and created Public intFileID As
I've created a plug-in that duck-punches the jQuery Ajax function. One problem that I
I am using a highly modified version of the jqueryFileTree plugin, that is able
I've created a simple plugin following tuts+ and modified it to do what I
I created a virtual keyboard with the following sample code. <script type=text/javascript> function vkb(vap){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.