Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Breadcrumbs question WordPress

  • SOLVED

I have a client with this issue and I am not sure of the best way to handle it. Curious if any of you have any ideas?

The goal is to add the text "Resources" (linking to a WP page created with the same name) to the breadcrumbs for a group of posts.

Specifically, categories of posts that are linked to from the Resources page.

So currently it reads:

On the Resources page, there is a list of text links, each are categories, all can be child categories of a Resources Category but in that instance, the breadcrumb with the text Resources will link to an archive page for the Resources page, not the static Resources page the client wants linked to.

http://184.172.177.95/~chinad/?page_id=435

Make sense? Anyone have any ideas on the best way to handle this?

I can do a screencast video if it would help my explanation

Thanks
Steve

Answers (4)

2012-05-25

Arnav Joy answers:

Hi Steve can you provide me access to your server , i can do it.
I did it something similar here
www.kitesurfbeaches.com

see the breadcrumb at inner pages

my email id is : [email protected]

skype : arnav.joy

thanks


Arnav Joy comments:

Hello Steve ,

please check and let me know if there is any issue.

-Arnav

2012-05-25

Francisco Javier Carazo Gil answers:

Hi Steve,

Now you have a loop that generate links to categories archives.

I have a question, have you got a static page for each category?

We have to change this loop, in order to make it link to static pages.


Steve Watson comments:

This might help explain

http://screencast.com/t/ndEs0dYdGzo

Thanks
Steve

2012-05-25

Daniel Yoen answers:

Sorry, I don't understand about your point, but I hope this script helps you :

put this script to functions.php

function breadcrumbs()
{
$delimiter = '»';
$name = 'Home';
$currentBefore = '<span class="current">';
$currentAfter = '</span>';

global $post;
$home = get_bloginfo('url');

if(is_home() && get_query_var('paged') == 0)
echo '<span class="home">' . $name . '</span>';
else
echo '<a class="home" href="' . $home . '">' . $name . '</a> '. $delimiter . ' ';

if ( is_category() )
{
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
echo $currentBefore;
single_cat_title();
echo $currentAfter;

}
elseif ( is_day() )
{
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
echo $currentBefore . get_the_time('d') . $currentAfter;
}
elseif ( is_month() )
{
echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
echo $currentBefore . get_the_time('F') . $currentAfter;
}
elseif ( is_year() )
{
echo $currentBefore . get_the_time('Y') . $currentAfter;
}
elseif ( is_single() )
{
$cat = get_the_category(); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo $currentBefore;
the_title();
echo $currentAfter;
}
elseif ( is_page() && !$post->post_parent )
{
echo $currentBefore;
the_title();
echo $currentAfter;
}
elseif ( is_page() && $post->post_parent )
{
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id)
{
$page = get_page($parent_id);
$breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
echo $currentBefore;
the_title();
echo $currentAfter;
}
elseif ( is_search() )
{
echo $currentBefore . 'Search for ' . get_search_query() . $currentAfter;
}
elseif ( is_tag() )
{
echo $currentBefore;
single_tag_title();
echo $currentAfter;
}
elseif ( is_author() )
{
global $author;
$userdata = get_userdata($author);
echo $currentBefore. $userdata->display_name . $currentAfter;
}
elseif ( is_404() )
{
echo $currentBefore . 'Error 404' . $currentAfter;
}
if ( get_query_var('paged') )
echo $currentBefore . __('Page') . ' ' . get_query_var('paged') . $currentAfter;
}

then, call the script from single.php

<?php breadcrumbs(); ?>


hope this help. :)

2012-05-25

Jatin Soni answers:

Okay so here I go. User below code and it should work as I have already tested for my site and it works completely fine.

Only you need to add url for your archive link at line 106
find:
<a href="here add your url to archive or where you want to link">

and replace "here add your url to archive or where you want to link" with your archive link. If you don't know how to do than give me the archive link I will do it for you.