show current post or page
-
I have this working so that Home displays but say I am on the about us post I don’t see any reference to this post. I would like it to work like this
Home (linked) About Us (not linked as current page)
How can I set this?
-
Frankly, I have got the same problem. Plugin works like charm except for posts/articles and pages. Weird is that it displays breadrcrumbs to custom pages made by another plugins like The Events Calendar for example.
Current pages and posts breadcrumbs are not shown though. Is there any way to fix it?
I use gantry 5 and Hydrogene theme.
How are you calling the breadcrumb trail? If you look at the HTML of the page in question (the one without the trail showing up), is there any indication that the breadcrumb trail should be there? That is, if you wrapped the call to
bcn_display()
in a div, is the div there?Yes, there is that trail there, but it only show one element (Homepage). Meta content in the div structure indicates “1” element to display, too.
It doesnt show current page though and current article or current post. Post categories are also visible on the trail, but posts are not.
It is really weird. I tried another breadcrumbs plugins, and weird is that they couldn’t handle other stuff (like The Events Calendar) but they worked well when it comes to posts and pages.
The
<meta property="position">
tag indicates the breadcrumb’s position in the trail, it is part of Schema.org’s BreadcrumbList specification.As for your actual issue, does the theme have an actual/traditional loop, or are they doing something else? Breadcrumb NavXT depends on the WordPress Conditionals to be correct at the time that
bcn_display()
is called. And, from what I can tell from the live demo of Hydrogene, some goofy things may be happening loop wise. Do you have any other plugins activated (just trying to rule out any goofy interactions)?I turned off all plugins but with no effect. I only was forced to keep Timber and Gantry 5 because they are crucial plugins to make Hydrogen theme works.
I have no idea what is wrong… If you would be willing to check files on my site that would be great.
Hi,
Gantry 5 developer here. We are using Timber library plugin as a WP library to provide Twig support for the G5 powered themes. The query and conditional tags should be fine. If you need to call a
bcn_display()
function in a Twig file you can try any of these :{{ function('bcn_display') }}
or
{{ wordpress.call('bcn_display') }}
They should be the same.
Thanks for answer! Both of these code snippets works, but the problem with the plugin still exists ;/
It only shows first element of the breadcrumb trail when it comes to pages (Homepage -> NOTHING) and posts (Homepage -> Category -> NOTHING). Buddy Press sites, The Event Calendar sites (and posts!) works fine.
I just played with the plugin and looks like it throws a notice when the $post object isn’t coming from the WP_Posts class, which causes the issue as we use Timber library and it’s classes.
Can you please try to edit the
/wp-content/plugins/breadcrumb-navxt/class.bcn_breadcrumb_trail.php
file and on line389
change this code :if(!is_object($post) || get_class($post) !== 'WP_Post')
to this :
if(!is_object($post) || (get_class($post) !== 'WP_Post' && get_class($post) !== 'Timber\Post'))
Did this worked ?
yes it did – thanks very much
Great! π @john can you please consider adding the modified code to your plugin ?
Thanks!
Modifying the
$post
global to not be aWP_Post
orWP_Error
object is not a good idea. Even worse is reimplementingWP_Post
rather than extending it. The check is there because this behavior is unexpected.However, the next version of Breadcrumb NavXT is moving away from trusting the
$post
global’s object (this has been slowly happening for a while now). Instead, it will use a different method and fetch the WP_Post object itself. This should work around this issue.I’m aware of that John, it was just a workaround to make it work with Timber library which we use as a Twig implementation for WordPress.
Thank you very much! It works perfect now! π
@jakku17 and @sherry22, can you try the infielder branch of Breadcrumb NavXT to see if it resolves this problem? See https://github.com/mtekk/Breadcrumb-NavXT/tree/infielder
I changed a couple of things that may work around this (no longer directly look at the$post
global).It works as well ;-). I just have tested it. Thanks!
- The topic ‘show current post or page’ is closed to new replies.