{"id":2030,"date":"2014-12-27T05:45:47","date_gmt":"2014-12-27T05:45:47","guid":{"rendered":"http:\/\/www.vishmax.com\/en\/?p=2030"},"modified":"2014-12-27T05:45:47","modified_gmt":"2014-12-27T05:45:47","slug":"wordpress-breadcrumbs-without-a-plugin","status":"publish","type":"post","link":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/","title":{"rendered":"WordPress breadcrumbs without a plugin"},"content":{"rendered":"<p>Breadcrumbs plays an important role in modern web design, now a days it becomes an essential part of web site navigation. Here is a function which will enable breadcrumbs on a WordPress blog with out a plugin.<\/p>\n<p>Add below function to your functions.php in WordPress theme and call the function &#8216;maxthemes_breadcrumbs&#8217;, where you want to display breadcrumbs.<\/p>\n<h2>Add to functions.php<\/h2>\n<pre lang=\"php\">\r\n\r\n<?php\r\nfunction maxthemes_breadcrumbs() {\r\n  $delimiter = '&raquo;';\r\n  $home = 'Home'; \/\/ text for the 'Home' link\r\n  $before = '<span class=\"current\">'; \/\/ tag before the current crumb\r\n  $after = '<\/span>'; \/\/ tag after the current crumb\r\n    echo '<div id=\"crumbs\">';\r\n    global $post;\r\n    $homeLink = home_url();\r\n    echo '<a href=\"' . $homeLink . '\">' . $home . '<\/a> ' . $delimiter . ' ';\r\n \r\n    if ( is_category() ) {\r\n      global $wp_query;\r\n      $cat_obj = $wp_query->get_queried_object();\r\n      $thisCat = $cat_obj->term_id;\r\n      $thisCat = get_category($thisCat);\r\n      $parentCat = get_category($thisCat->parent);\r\n      if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));\r\n      echo $before . 'View by \"' . single_cat_title('', false) . '\"' . $after;\r\n \r\n    } elseif ( is_day() ) {\r\n      echo '<a href=\"' . get_year_link(get_the_time('Y')) . '\">' . get_the_time('Y') . '<\/a> ' . $delimiter . ' ';\r\n      echo '<a href=\"' . get_month_link(get_the_time('Y'),get_the_time('m')) . '\">' . get_the_time('F') . '<\/a> ' . $delimiter . ' ';\r\n      echo $before . get_the_time('d') . $after;\r\n \r\n    } elseif ( is_month() ) {\r\n      echo '<a href=\"' . get_year_link(get_the_time('Y')) . '\">' . get_the_time('Y') . '<\/a> ' . $delimiter . ' ';\r\n      echo $before . get_the_time('F') . $after;\r\n \r\n    } elseif ( is_year() ) {\r\n      echo $before . get_the_time('Y') . $after;\r\n \r\n    } elseif ( is_single() && !is_attachment() ) {\r\n      if ( get_post_type() != 'post' ) {\r\n        $post_type = get_post_type_object(get_post_type());\r\n        $slug = $post_type->rewrite;\r\n        echo '<a href=\"' . $homeLink . '\/' . $slug['slug'] . '\/\">' . $post_type->labels->singular_name . '<\/a> ' . $delimiter . ' ';\r\n        echo $before . get_the_title() . $after;\r\n      } else {\r\n        $cat = get_the_category(); $cat = $cat[0];\r\n        echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');\r\n        echo $before . get_the_title() . $after;\r\n      } \r\n    } elseif ( is_attachment() ) {\r\n      $parent = get_post($post->post_parent);\r\n      \/\/$cat = get_the_category($parent->ID); $cat = $cat[0];\r\n      \/\/echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');\r\n      echo '<a href=\"' . get_permalink($parent) . '\">' . $parent->post_title . '<\/a> ' . $delimiter . ' ';\r\n      echo $before . get_the_title() . $after; \r\n    } elseif ( is_page() && !$post->post_parent ) {\r\n      echo $before . get_the_title() . $after;\r\n \r\n    } elseif ( is_page() && $post->post_parent ) {\r\n      $parent_id  = $post->post_parent;\r\n      $breadcrumbs = array();\r\n      while ($parent_id) {\r\n        $page = get_page($parent_id);\r\n        $breadcrumbs[] = '<a href=\"' . get_permalink($page->ID) . '\">' . get_the_title($page->ID) . '<\/a>';\r\n        $parent_id  = $page->post_parent;\r\n      }\r\n      $breadcrumbs = array_reverse($breadcrumbs);\r\n      foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';\r\n      echo $before . get_the_title() . $after;\r\n \r\n    } elseif ( is_search() ) {\r\n      echo $before . 'Search results for \"' . get_search_query() . '\"' . $after;\r\n \r\n    } elseif ( is_tag() ) {\r\n      echo $before . 'Posts tagged \"' . single_tag_title('', false) . '\"' . $after;\r\n \r\n    } elseif ( is_author() ) {\r\n       global $author;\r\n      $userdata = get_userdata($author);\r\n      echo $before . 'Articles posted by ' . $userdata->display_name . $after;\r\n \r\n    } elseif ( is_404() ) {\r\n      echo $before . 'Error 404' . $after;\r\n    }\r\n \r\n    if ( get_query_var('paged') ) {\r\n      if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';\r\n      echo ' - Page' . ' ' . get_query_var('paged');\r\n      if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';\r\n    }\r\n \r\n    echo '&nbsp;&nbsp;<\/div>';\r\n}\r\n\r\n?>\r\n\r\n<\/pre>\n<h2>Call the above function on WordPress template<\/h2>\n<pre lang=\"php\">\r\n\r\n<?php if (function_exists('maxthemes_breadcrumbs')) maxthemes_breadcrumbs(); ?>\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Breadcrumbs plays an important role in modern web design, now a days it becomes an essential part of web site navigation. Here is a function which will enable breadcrumbs on a WordPress blog with out a plugin. Add below function to your functions.php in WordPress theme and call the function &#8216;maxthemes_breadcrumbs&#8217;, where you want to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[44],"tags":[72,83],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WordPress breadcrumbs without a plugin - Vishmax.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WordPress breadcrumbs without a plugin - Vishmax.com\" \/>\n<meta property=\"og:description\" content=\"Breadcrumbs plays an important role in modern web design, now a days it becomes an essential part of web site navigation. Here is a function which will enable breadcrumbs on a WordPress blog with out a plugin. Add below function to your functions.php in WordPress theme and call the function &#8216;maxthemes_breadcrumbs&#8217;, where you want to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/\" \/>\n<meta property=\"og:site_name\" content=\"Vishmax.com\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-27T05:45:47+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93\"},\"headline\":\"WordPress breadcrumbs without a plugin\",\"datePublished\":\"2014-12-27T05:45:47+00:00\",\"dateModified\":\"2014-12-27T05:45:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/\"},\"wordCount\":75,\"publisher\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#organization\"},\"keywords\":[\"Code Library\",\"WP Snippets\"],\"articleSection\":[\"Labs\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/\",\"url\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/\",\"name\":\"WordPress breadcrumbs without a plugin - Vishmax.com\",\"isPartOf\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#website\"},\"datePublished\":\"2014-12-27T05:45:47+00:00\",\"dateModified\":\"2014-12-27T05:45:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.vishmax.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress breadcrumbs without a plugin\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#website\",\"url\":\"http:\/\/www.vishmax.com\/en\/\",\"name\":\"Vishmax.com\",\"description\":\"Software Company in Calicut for Web Design and eCommerce\",\"publisher\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.vishmax.com\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#organization\",\"name\":\"Vishmax.com\",\"url\":\"http:\/\/www.vishmax.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png\",\"contentUrl\":\"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png\",\"width\":150,\"height\":50,\"caption\":\"Vishmax.com\"},\"image\":{\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g\",\"caption\":\"admin\"},\"url\":\"https:\/\/www.vishmax.com\/en\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WordPress breadcrumbs without a plugin - Vishmax.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/","og_locale":"en_US","og_type":"article","og_title":"WordPress breadcrumbs without a plugin - Vishmax.com","og_description":"Breadcrumbs plays an important role in modern web design, now a days it becomes an essential part of web site navigation. Here is a function which will enable breadcrumbs on a WordPress blog with out a plugin. Add below function to your functions.php in WordPress theme and call the function &#8216;maxthemes_breadcrumbs&#8217;, where you want to [&hellip;]","og_url":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/","og_site_name":"Vishmax.com","article_published_time":"2014-12-27T05:45:47+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/#article","isPartOf":{"@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/"},"author":{"name":"admin","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93"},"headline":"WordPress breadcrumbs without a plugin","datePublished":"2014-12-27T05:45:47+00:00","dateModified":"2014-12-27T05:45:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/"},"wordCount":75,"publisher":{"@id":"http:\/\/www.vishmax.com\/en\/#organization"},"keywords":["Code Library","WP Snippets"],"articleSection":["Labs"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/","url":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/","name":"WordPress breadcrumbs without a plugin - Vishmax.com","isPartOf":{"@id":"http:\/\/www.vishmax.com\/en\/#website"},"datePublished":"2014-12-27T05:45:47+00:00","dateModified":"2014-12-27T05:45:47+00:00","breadcrumb":{"@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vishmax.com\/en\/labs\/wordpress-breadcrumbs-without-a-plugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.vishmax.com\/en\/"},{"@type":"ListItem","position":2,"name":"WordPress breadcrumbs without a plugin"}]},{"@type":"WebSite","@id":"http:\/\/www.vishmax.com\/en\/#website","url":"http:\/\/www.vishmax.com\/en\/","name":"Vishmax.com","description":"Software Company in Calicut for Web Design and eCommerce","publisher":{"@id":"http:\/\/www.vishmax.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.vishmax.com\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/www.vishmax.com\/en\/#organization","name":"Vishmax.com","url":"http:\/\/www.vishmax.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png","contentUrl":"https:\/\/www.vishmax.com\/en\/wp-content\/uploads\/2023\/03\/logo-vishmax.png","width":150,"height":50,"caption":"Vishmax.com"},"image":{"@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/785fa94b56eb17ae7706d30777d6ab93","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.vishmax.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e218268870406c917d20b442936d9e68?s=96&d=monsterid&r=g","caption":"admin"},"url":"https:\/\/www.vishmax.com\/en\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts\/2030"}],"collection":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/comments?post=2030"}],"version-history":[{"count":0,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/posts\/2030\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/media?parent=2030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/categories?post=2030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vishmax.com\/en\/wp-json\/wp\/v2\/tags?post=2030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}