logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$30
Breadcrumbs question

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

This question has been answered.

Steve Watson | 05/25/12 at 11:04am Edit


(4) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    05/25/12
    11:12am
    Francisco Javier Carazo Gil says:

    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.

    • 05/25/12 11:59am

      Steve Watson says:

      This might help explain

      http://screencast.com/t/ndEs0dYdGzo

      Thanks
      Steve

  • avatar
    Last edited:
    05/25/12
    11:24am
    Daniel Yoen says:

    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. :)

  • avatar
    Last edited:
    05/26/12
    5:08am
    Jatin Soni says:

    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.

    Previous versions of this answer: 05/25/12 at 12:30pm | 05/26/12 at 5:08am

  • avatar
    Last edited:
    05/25/12
    12:56pm
    Arnav Joy says:

    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 : thearnavjoy@gmail.com

    skype : arnav.joy

    thanks

    • 05/25/12 4:07pm

      Arnav Joy says:

      Hello Steve ,

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

      -Arnav

This question has expired.



Steve Watson, Gabriel Reguly voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.