{"id":151,"date":"2014-06-18T11:17:59","date_gmt":"2014-06-18T11:17:59","guid":{"rendered":"http:\/\/localhost\/syllogic\/wp\/?p=151"},"modified":"2024-02-02T12:22:27","modified_gmt":"2024-02-02T12:22:27","slug":"fixing-custom-post-breadcrumbs","status":"publish","type":"post","link":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/","title":{"rendered":"Fixing Custom Post breadcrumbs"},"content":{"rendered":"\n

When using a ready made theme such as one of the excellent Elegant Themes one is confronted to small issues of broken sections of the page templates when introducing custom post and getting them to display properly in the page templates<\/p>\n\n\n\n

One such issue is the breadcrumbs link not working properly as a result of the custom taxonomies not being picked up properly by the core functions.  Here is some workaround for this.<\/p>\n\n\n\n

In the case of the Elegant themes, you will find the breadcrumbs.php<\/code> file in the includes\/<\/code> directory.<\/p>\n\n\n\n

So for example in the single post page template, the breadcrumbs are displayed using the following code.<\/p>\n\n\n\n

...\n\/\/some code to display the authors link followed by\n$category = get_the_category(); \/\/returns the categories of this post\n$catlink = get_category_link( $category[0]->cat_ID ); \/\/gets the links for the first category\necho ('<a href=\"'.esc_url($catlink).'\">'.esc_html($category[0]->cat_name).'<\/a> '.'<span class=\"raquo\">&raquo;<\/span> '.get_the_title()); \n\/\/displays the category in the breadcrumb\n<\/code><\/pre>\n\n\n\n

So we can include the following lines in order to ensure it works with our custom post<\/p>\n\n\n\n

global $post; \/\/we need to ensure we have access to the post object breadcrumbs are handled in its own template\n...\nswitch ( get_post_type($post) ){ \/\/switch on the post_type\n  case 'my_custom_post_type': \/\/\n    $category = get_the_terms($post->ID, 'my_custom_taxonomy');\n    $first_term = reset($category);\n    $catlink = get_term_link( $first_term );\n    echo (''.esc_html($first_term->name).'<\/a> '.'\u00bb<\/span> '.get_the_title());\n    break;\n  default: \/\/default 'post'and below is the default code \n    $category = get_the_category();\n    $catlink = get_category_link( $category[0]->cat_ID );\n    echo (''.esc_html($category[0]->cat_name).'<\/a> '.'\u00bb<\/span> '.get_the_title());\n    break;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

When using a ready made theme such as one of the excellent Elegant Themes one is confronted to small issues of broken sections of the page templates when introducing custom post and getting them to display properly in the page templates One such issue is the breadcrumbs link not working properly as a result of […]<\/p>\n","protected":false},"author":2,"featured_media":319,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"yoast_head":"\nFixing Custom Post breadcrumbs - Tiffin Consulting<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fixing Custom Post breadcrumbs - Tiffin Consulting\" \/>\n<meta property=\"og:description\" content=\"When using a ready made theme such as one of the excellent Elegant Themes one is confronted to small issues of broken sections of the page templates when introducing custom post and getting them to display properly in the page templates One such issue is the breadcrumbs link not working properly as a result of […]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/\" \/>\n<meta property=\"og:site_name\" content=\"Tiffin Consulting\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-18T11:17:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-02T12:22:27+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/localhost:10008\/wp-content\/uploads\/2015\/07\/Wordpress-Code-is-Poetry.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1038\" \/>\n\t<meta property=\"og:image:height\" content=\"1038\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Aurovrata V.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Aurovrata V.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t \"@context\": \"https:\/\/schema.org\",\n\t \"@graph\": [\n\t {\n\t \"@type\": \"Article\",\n\t \"@id\": \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/#article\",\n\t \"isPartOf\": {\n\t \"@id\": \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/\"\n\t },\n\t \"author\": {\n\t \"name\": \"Aurovrata V.\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99\"\n\t },\n\t \"headline\": \"Fixing Custom Post breadcrumbs\",\n\t \"datePublished\": \"2014-06-18T11:17:59+00:00\",\n\t \"dateModified\": \"2024-02-02T12:22:27+00:00\",\n\t \"mainEntityOfPage\": {\n\t \"@id\": \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/\"\n\t },\n\t \"wordCount\": 127,\n\t \"publisher\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6\"\n\t },\n\t \"articleSection\": [\n\t \"News & Updates\"\n\t ],\n\t \"inLanguage\": \"en-US\"\n\t },\n\t {\n\t \"@type\": \"WebPage\",\n\t \"@id\": \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/\",\n\t \"url\": \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/\",\n\t \"name\": \"Fixing Custom Post breadcrumbs - Tiffin Consulting\",\n\t \"isPartOf\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#website\"\n\t },\n\t \"datePublished\": \"2014-06-18T11:17:59+00:00\",\n\t \"dateModified\": \"2024-02-02T12:22:27+00:00\",\n\t \"breadcrumb\": {\n\t \"@id\": \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/#breadcrumb\"\n\t },\n\t \"inLanguage\": \"en-US\",\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"ReadAction\",\n\t \"target\": [\n\t \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/\"\n\t ]\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"BreadcrumbList\",\n\t \"@id\": \"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/#breadcrumb\",\n\t \"itemListElement\": [\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 1,\n\t \"name\": \"Home\",\n\t \"item\": \"http:\/\/localhost:10008\/\"\n\t },\n\t {\n\t \"@type\": \"ListItem\",\n\t \"position\": 2,\n\t \"name\": \"Fixing Custom Post breadcrumbs\"\n\t }\n\t ]\n\t },\n\t {\n\t \"@type\": \"WebSite\",\n\t \"@id\": \"http:\/\/localhost:10008\/#website\",\n\t \"url\": \"http:\/\/localhost:10008\/\",\n\t \"name\": \"Tiffin Consulting\",\n\t \"description\": \"digital business transformation\",\n\t \"publisher\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6\"\n\t },\n\t \"potentialAction\": [\n\t {\n\t \"@type\": \"SearchAction\",\n\t \"target\": {\n\t \"@type\": \"EntryPoint\",\n\t \"urlTemplate\": \"http:\/\/localhost:10008\/?s={search_term_string}\"\n\t },\n\t \"query-input\": \"required name=search_term_string\"\n\t }\n\t ],\n\t \"inLanguage\": \"en-US\"\n\t },\n\t {\n\t \"@type\": [\n\t \"Person\",\n\t \"Organization\"\n\t ],\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6\",\n\t \"name\": \"Aurovrata V.\",\n\t \"image\": {\n\t \"@type\": \"ImageObject\",\n\t \"inLanguage\": \"en-US\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/image\/\",\n\t \"url\": \"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png\",\n\t \"contentUrl\": \"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png\",\n\t \"width\": 1060,\n\t \"height\": 644,\n\t \"caption\": \"Aurovrata V.\"\n\t },\n\t \"logo\": {\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/image\/\"\n\t },\n\t \"sameAs\": [\n\t \"http:\/\/localhost:10008\"\n\t ]\n\t },\n\t {\n\t \"@type\": \"Person\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99\",\n\t \"name\": \"Aurovrata V.\",\n\t \"image\": {\n\t \"@type\": \"ImageObject\",\n\t \"inLanguage\": \"en-US\",\n\t \"@id\": \"http:\/\/localhost:10008\/#\/schema\/person\/image\/\",\n\t \"url\": \"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\n\t \"contentUrl\": \"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g\",\n\t \"caption\": \"Aurovrata V.\"\n\t },\n\t \"url\": \"http:\/\/localhost:10008\/author\/aurovrata\/\"\n\t }\n\t ]\n\t}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fixing Custom Post breadcrumbs - Tiffin Consulting","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":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/","og_locale":"en_US","og_type":"article","og_title":"Fixing Custom Post breadcrumbs - Tiffin Consulting","og_description":"When using a ready made theme such as one of the excellent Elegant Themes one is confronted to small issues of broken sections of the page templates when introducing custom post and getting them to display properly in the page templates One such issue is the breadcrumbs link not working properly as a result of […]","og_url":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/","og_site_name":"Tiffin Consulting","article_published_time":"2014-06-18T11:17:59+00:00","article_modified_time":"2024-02-02T12:22:27+00:00","og_image":[{"width":1038,"height":1038,"url":"http:\/\/localhost:10008\/wp-content\/uploads\/2015\/07\/Wordpress-Code-is-Poetry.png","type":"image\/png"}],"author":"Aurovrata V.","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Aurovrata V.","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/#article","isPartOf":{"@id":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/"},"author":{"name":"Aurovrata V.","@id":"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99"},"headline":"Fixing Custom Post breadcrumbs","datePublished":"2014-06-18T11:17:59+00:00","dateModified":"2024-02-02T12:22:27+00:00","mainEntityOfPage":{"@id":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/"},"wordCount":127,"publisher":{"@id":"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6"},"articleSection":["News & Updates"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/","url":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/","name":"Fixing Custom Post breadcrumbs - Tiffin Consulting","isPartOf":{"@id":"http:\/\/localhost:10008\/#website"},"datePublished":"2014-06-18T11:17:59+00:00","dateModified":"2024-02-02T12:22:27+00:00","breadcrumb":{"@id":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/localhost:10008\/fixing-custom-post-breadcrumbs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/localhost:10008\/"},{"@type":"ListItem","position":2,"name":"Fixing Custom Post breadcrumbs"}]},{"@type":"WebSite","@id":"http:\/\/localhost:10008\/#website","url":"http:\/\/localhost:10008\/","name":"Tiffin Consulting","description":"digital business transformation","publisher":{"@id":"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/localhost:10008\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/localhost:10008\/#\/schema\/person\/e7549052d5ca8cb5891c059c2424a9f6","name":"Aurovrata V.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/localhost:10008\/#\/schema\/person\/image\/","url":"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png","contentUrl":"http:\/\/localhost:10008\/wp-content\/uploads\/2024\/02\/tiffin-dabbawalla.png","width":1060,"height":644,"caption":"Aurovrata V."},"logo":{"@id":"http:\/\/localhost:10008\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/localhost:10008"]},{"@type":"Person","@id":"http:\/\/localhost:10008\/#\/schema\/person\/361f7db128e2b6858c7deb2a43f85f99","name":"Aurovrata V.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/localhost:10008\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g","caption":"Aurovrata V."},"url":"http:\/\/localhost:10008\/author\/aurovrata\/"}]}},"_links":{"self":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts\/151"}],"collection":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":1,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":347,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/posts\/151\/revisions\/347"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/media\/319"}],"wp:attachment":[{"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/categories?post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:10008\/wp-json\/wp\/v2\/tags?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}