Breadcrumbs, for those in need :)

Finally I've managed to do what I wanted(add breadrumbs). So, If you need to add breadcrumbs to marketpress, add this to functions.php of your theme. Then you must add <?php the_breadcrumb() ;?> where you want to place them, and style them using css.

function the_breadcrumb() {
	if (!is_home()) {
		echo '<a href="';
		echo get_option('home');
		echo '">';
		bloginfo('name');
		echo " » ";
		if (is_category() || is_single()) {
			$ID = $wp_query->post->ID;
			$categoria = mp_category_list($ID);
			echo $categoria;
			if (is_single()) {
				echo " » ";
				the_title();
			}
		} elseif (is_page()) {
			echo the_title();
		}
	}
}

I've added <?php the_breadcrumb() ;?> inside a div, like this
<div class="breadcrumbs"><?php the_breadcrumb(); ?></div>

and this is the css that I've used :

#content .breadcrumbs{
	width:100%;
	float:left;
	color:#E02D30;
	font-size:10px;
}
#content .breadcrumbs a{
	color:#E02D30;
}
  • Philip John
    • DEV MAN’s Apprentice

    Hiya!

    This is great, thanks so much for donating that code! Hopefully this will come in handy for others. Rep points heading your way.

    One tip for ya: when pasting code, highlight it and then hit the "code" button just above the box. That'll format your code nicely. I've done that for you in your original post so you can see it in action.

    Cheers!
    Phil

  • Jonathan
    • The Incredible Code Injector

    @Jimmy Symmonds

    They show where the person is in the greater scheme of things.

    Example:
    Home > Page level One > Page level Two > Page Level Three > Page level Four > Current Page

    Reading Material:
    http://en.wikipedia.org/wiki/Breadcrumb_(navigation)

    Edit: Oops forgot to say good job JM :wink:
    I've got a very complicated breadcrumb setup, but this is simple and easy enough - so I think you are going to help a few folks with this :wink:

  • JM
    • Design Lord, Child of Thor

    Hi Phil,

    I hope that is useful. (it is for me:grinning:. I know about that code formatting, and I've tried it but it didn't worked, so I thought i don't have the right to do that or something.

    Jimmy, breadcrumbs are just like you see above the title of this post.

    WPMU DEV - The WordPress Experts » Plugin Support

    "Breadcrumbs or breadcrumb trail is a navigation aid used in user interfaces"(wikipedia), and I think it's good for SEO.

    Thanks for modifying my post Phil!
    JM

  • Jonathan
    • The Incredible Code Injector

    @JM
    You posted over me and I forgot to refresh...

    Edit: Oops forgot to say good job JM :wink:
    I've got a very complicated breadcrumb setup, but this is simple and easy enough - so I think you are going to help a few folks with this :wink:

  • JM
    • Design Lord, Child of Thor

    Thanks Phil!
    Jimmy, this function as it is would only work on single pages, or category pages, so you can insert it inside your single.php or you can make a mp_product.php (which i think it's best.). If you are not familiar with how wordpress works and you don't have knowldege of html and php, then it's a bit tricky. Maybe if you tell me more about what you need exactly and what are your programming knowledge i could help you.

    All the best,
    JM

  • in-mn
    • The Crimson Coder

    if you modify your theme, it will be sitewide. Choosing to employ it but you would have to add it to the page you want it on.

    Correct me if i am wrong, you could ADD the <div...>to a page template, and anything using that template would have the breadcrumb script, correct? If so - would that retroactively update?

    Edit, i forgot my manners. Many thanks!

  • in-mn
    • The Crimson Coder

    theres a bug in the code line 7, it should be this:

    function the_breadcrumb() {
    	if (!is_home()) {
    		echo '<a href="';
    		echo get_option('home');
    		echo '">';
    		bloginfo('name');
    		echo "</a> » ";
    		if (is_category() || is_single()) {
    			$ID = $wp_query->post->ID;
    			$categoria = mp_category_list($ID);
    			echo $categoria;
    			if (is_single()) {
    				echo "</a> » ";
    				the_title();
    			}
    		} elseif (is_page()) {
    			echo the_title();
    		}
    	}
    }
  • sbahns
    • WPMU DEV Initiate

    Any tips on excluding a category from appearing? I have a category called "catalog" where I have everything listed, but I don't want it to appear in the breadcrumbs. I tried using the standard args (eg. 'exclude=329&title_li='), but that apparently doesn't do anything with this function. Any suggestions?

  • nickrosener
    • Flash Drive

    These are extremely poor breadcrumbs. If you look, you will see that it does not work for the vast majority of pages, and posses a major flaw on the blog. either way, tons missing.. see this:

    http://stackoverflow.com/questions/12798256/breadcrumbs-marketpress

    Specifically I am stuck on how to decide what breadcrumb is shown on the Product List page (mp_product_list.php)

    jquery vars 'pagename' not working.. $templates = array(' not working.. is_page_template not working..

    see stackoverflow post..

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.