WordPress.org

Ready to get started?Download WordPress

Forums

Breadcrumb NavXT
[resolved] Breadcrumb Links Don't Change To Say Page You're On... (9 posts)

  1. PGrizz
    Member
    Posted 3 years ago #

    Hey, great plugin, but we’re having a problem with the same breadcrumb links being displayed no matter what post we’re on.

    For example: The page “Brand New Post for Breadcrumbs” displays “Home > Video Game Reviews > Video Game Reviews (2011): Test Post” instead of what it should be displaying which would be “Home > In Theaters > Brand New Post for Breadcrumbs “

    You can see what I’m talking about here on our site’s test website: http://tinyurl.com/4wjfjf4

  2. John Havlik
    Member
    Plugin Author

    Posted 3 years ago #

    Yeah, don't use the $post variable in secondary/custom loops. If you must use $post, you must restore it back to its original state after you are done with your secondary loop.

  3. PGrizz
    Member
    Posted 3 years ago #

    Sorry, I'm not that familiar with customizing loops, any advice on how I can go about restoring it back to its original state because it looks like the theme needs $post. Although, I'm not 100% sure if the theme needs $post either...

  4. John Havlik
    Member
    Plugin Author

    Posted 3 years ago #

    Whatever code is generating the six articles on the top of the page is the $post variable abuser (the stuff inside of the ul with class "highlights2"). I'd bug the creator of it to fix their stuff.

  5. PGrizz
    Member
    Posted 3 years ago #

    Unfortunately, the theme is heavily modified, and besides the breadcrumbs plugins, everything else seems to function fine with the modifications. You're right about where the problem is. Each one of the six articles in the top is generated by this code:

    <ul class="highlights2">
    		<?php $highlight7 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_7')."&showposts=1"); while($highlight7->have_posts()) : $highlight7->the_post();
    $highlightcat7 = get_wpn_config('highlights_category_id_7');
    $highlightcatname7 = get_cat_name( $highlightcat7 );
    $cat7_string.='<a href="'.get_category_link( $highlightcat7 ).'">'.$highlightcatname7.'</a>';?>
    			<li>
    			<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
    				<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
    			<?php endif; ?>
    				<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
    				<span class="cat"><?php echo $cat7_string; ?></span>
    			</li>
    		<?php endwhile; ?>
    		</ul>

    it looks like this part of that code is what causes the problem: `<?php $highlight7 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_7')."&showposts=1"); while($highlight7->have_posts()) : $highlight7->the_post();
    $highlightcat7 = get_wpn_config('highlights_category_id_7');
    $highlightcatname7 = get_cat_name( $highlightcat7 );
    $cat7_string.='<a href="'.get_category_link( $highlightcat7 ).'">'.$highlightcatname7.'</a>';?> (code that isn't causing the error) <?php endwhile; ?>`

    If you look at the part that is causing the error, it doesn't actually contain the $post. Since it looks like I can't edit it without it breaking my desired functionality, how can I restore it back to its original state after it's done?

  6. John Havlik
    Member
    Plugin Author

    Posted 3 years ago #

    Ok, that's interesting. I'm going to have to look into this a little more.

  7. John Havlik
    Member
    Plugin Author

    Posted 3 years ago #

    Ok, after looking into this a little, you should try calling wp_reset_query() after that custom loop code. See http://codex.wordpress.org/Function_Reference/wp_reset_query for more information on that function. Let me know if that resolves the issue.

  8. PGrizz
    Member
    Posted 3 years ago #

    yep, that fixed it! really appreciate you going out of your way to help solve the problem, thanks again! :)

  9. Eek
    Member
    Posted 3 years ago #

    I had the same problem... Don't know how I managed to forget to reset the query :( What a headache!

    Thanks mtekk >:D<

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic