www.webdeveloper.com
Results 1 to 4 of 4

Thread: Simple .php code modification

  1. #1
    Join Date
    Sep 2006
    Posts
    79

    Simple .php code modification

    Hi,

    I think this is really simple to do, but I don't know .php well enough to know what code to modify. Please see this URL:

    http://caspca.org/wordpress/voluntee...r-at-the-spca/

    I've added a breadcrumbs to the site. All I want to do is modify the breadcrumb code to eliminate the home page link "Charlottesville-Albemarle SPCA" and replace it with simple text (NOT a link) that reads "How you got to this page:" - I want the link path to start from the top nav menu item (in this case, "Vol / Foster". In other words it'll look like this:

    How you got to this page: <a href="http://caspca.org/wordpress/volunteerfoster/">Volunteer/Foster</a>
    Adult Volunteers at the SPCA

    Here is the .php:

    Code:
    function simple_breadcrumb() {
        global $post;
        echo '<div class="breadcrumb">';
    	if (!is_front_page()) {
    		echo '<a href="';
    		echo get_option('home');
    		echo '">';
    		bloginfo('name');
    		echo "</a>  ";
    		if ( is_category() || is_single() ) {
    			the_category(', ');
    			if ( is_single() ) {
    				echo "  ";
    				the_title();
    			}
    		} elseif ( is_page() && $post->post_parent ) {
    			$home = get_page_by_title('home');
    			for ($i = count($post->ancestors)-1; $i >= 0; $i--) {
    				if (($home->ID) != ($post->ancestors[$i])) {
    					echo '<a href="';
    					echo get_permalink($post->ancestors[$i]); 
    					echo '">';
    					echo get_the_title($post->ancestors[$i]);
    					echo "</a>  ";
    				}
    			}
    			echo the_title();
    		} elseif (is_page()) {
    			echo the_title();
    		} elseif (is_404()) {
    			echo "404";
    		}
    	} else {
    		bloginfo('name');
    	}
    	echo '</div>';
    Thank you!

    John

  2. #2
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    448
    Try commenting out

    bloginfo('name');

    to

    //bloginfo('name');

  3. #3
    Join Date
    Sep 2006
    Posts
    79
    Hi Chris,

    That worked, also had to comment out:

    //echo "</a> ";

    to get rid of the ">>" ... but to complete the 2nd part of what I'd like to do, how do I modify the code to begin the breadcrumb with "How you got to this page:" and I don't want to make that a link, just text.

    Thanks so much,

    John

  4. #4
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    448
    You need to insert a

    echo "How you got to this page:" ;

    right at the beginning of the breadcrumb.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles