justintadlock / breadcrumb-trail

Official home of the Breadcrumb Trail plugin for WordPress.
GNU General Public License v2.0
136 stars 61 forks source link

Ajax Loaded Posts #40

Closed anteksiler closed 6 years ago

anteksiler commented 6 years ago

When the breadcrumb is in a ajax loaded post, it only displays 'Home'.

justintadlock commented 6 years ago

More information is required.

anteksiler commented 6 years ago

Hi there, what kind of information do you want? I am loading the posts via ajax using: $args = array( 'p' => $previous_post->ID, 'no_found_rows' => true, 'posts_per_page' => 1, 'post_status' => 'publish' ); $query = new WP_Query($args);

Using this in an infinite post style, where previous article is loaded when you reach the end of the page.

justintadlock commented 6 years ago

I need step-by-step information on how to recreate the issue.

Generally speaking, it'd be up to you to write the code to "reload" the breadcrumbs for a custom, Ajax-based system. I imagine it'd be impossible for BT to detect custom systems from themes/plugins. If it's something that I think would be a good fit for BT, I'd certainly consider it.

anteksiler commented 6 years ago

I am getting the whole post content on Ajax, so it is not a javascript based system where I load certain parts.

Every content of the post is correct, except for the breadcrumbs. It is in a reqular WP_Query. I am not sure why it is failing. You are getting the correct ID using: $post = get_queried_object(); $post_id = get_queried_object_id();

anteksiler commented 6 years ago

Actually, the below code is not triggered: elseif ( is_singular() ) { $this->add_singular_items(); }

anteksiler commented 6 years ago

You can view it here: http://ftgoodlife.staging.wpengine.com/entertainment/tamar-braxton-joins-nick-carter-chaka-khan-andy-grammer-on-dancing-with-the-stars/ Just scroll bottom and let the next article load.

justintadlock commented 6 years ago

If you've got a theme Git/SVN repo to point me to, I'd be happy to take a look when I get some free time. Or, if you can describe in full detail the steps (with code) I need to recreate the issue, that's OK too.

Outside of that, this ticket is pretty much dead in the water.

anteksiler commented 6 years ago

I think I solved the issue. Since it's an ajax call, it is not singular, it is from Admin. So change the line to: elseif ( is_singular() || is_admin()) {