コード例 #1
0
function thb_breadcrumb()
{
    global $post, $wp_query;
    $id = $wp_query->get_queried_object_id();
    echo '<aside class="breadcrumb">';
    if (!is_front_page()) {
        echo '<a href="';
        echo home_url();
        echo '">' . __('Home', THB_THEME_NAME);
        echo "</a>";
    }
    if (is_singular('portfolio')) {
        $portfolio_main = get_post_meta($post->ID, 'portfolio_main', TRUE);
        if ($portfolio_main) {
            $portfolio_link = get_permalink($portfolio_main);
        } else {
            $portfolio_link = get_portfolio_page_link(get_the_ID());
        }
        echo '<span>/</span> <a href="' . $portfolio_link . '">' . __('Portfolio', THB_THEME_NAME) . '</a>';
        echo '<span>/</span>' . get_the_title();
    }
    if (is_home()) {
        echo '<span>/</span>' . __('Blog', THB_THEME_NAME);
    }
    if (is_page() && !is_front_page()) {
        $parents = array();
        $parent_id = $post->post_parent;
        while ($parent_id) {
            $page = get_page($parent_id);
            $parents[] = '<span>/</span><a href="' . get_permalink($page->ID) . '" title="' . get_the_title($page->ID) . '">' . get_the_title($page->ID) . '</a>';
            $parent_id = $page->post_parent;
        }
        $parents = array_reverse($parents);
        echo join(' ', $parents);
        echo '<span>/</span>' . get_the_title();
    }
    if (is_single() && !is_singular('portfolio')) {
        $categories = get_the_category();
        if ($categories) {
            foreach ($categories as $cat) {
                $cats[] = '<a href="' . get_category_link($cat->term_id) . '" title="' . $cat->name . '">' . $cat->name . '</a>';
            }
            echo '<span>/</span>' . join(', ', $cats);
        }
        echo '<span>/</span>' . ShortenText(get_the_title(), 40);
    }
    if (is_archive()) {
        if (class_exists('woocommerce') && is_woocommerce() && is_shop()) {
            echo '<span>/</span>' . get_the_title(wc_get_page_id('shop'));
        } else {
            echo '<span>/</span>' . thb_which_archive();
        }
    }
    if (is_search()) {
        echo '<span>/</span>' . thb_which_archive();
    }
    echo '</aside>';
}
コード例 #2
0
if (!is_singular('portfolio') && !is_singular('product') && $display_breadcrumbs != 'off' && !is_404()) {
    ?>
<!-- Start Breadcrumbs -->
<div id="breadcrumbs">
<div class="row">
	<div class="small-12 columns">
		<div class="main-header">
			<div class="row">
				<div class="small-12 medium-6 columns">
					<h1>
						<?php 
    if (class_exists('woocommerce') && is_woocommerce()) {
        woocommerce_page_title();
    } else {
        if (is_archive() || is_search()) {
            echo thb_title(array('title' => thb_which_archive()));
        } else {
            if (is_singular('post')) {
                echo thb_title(false, $postspage_id);
            } else {
                echo thb_title();
            }
        }
    }
    ?>
					
					</h1>
				</div>
				<div class="small-12 medium-6 columns hide-for-small">
						<?php 
    if (class_exists('woocommerce') && is_woocommerce()) {