Tạo Breadcrumb đẹp cho wordpress không dùng plugin

5/5 - (1 bình chọn)
Breadcrumb là một tính năng cho phép người dùng điều hướng đến trang mà họ muốn. Tính năng này cũng rất quan trọng cho SEO. Tuy nhiên, trong phiên bản lần đầu mình gửi cho một số bạn. Nếu để ý chúng ta sẽ thấy không có chức năng đường dẫn Breadcrumb. Do đó, bài viết này mình hướng dẫn các bạn tạo Breadcrumb đẹp và phù hợp cho giao diện này.
Code Tạo Breadcrumb đẹp cho wordpress không dùng plugin

Bước 1: Các bạn copy đoạn code bên dưới và paste vào trong file function.php (giao diện > chỉnh sửa > tìm file function.php để sửa). Việc copy đoạn code này ném vô function.php là khởi tạo tính năng breadcrumb cho website.

function the_breadcrumb() {

                echo '<ul id="crumbs">';

        if (!is_home()) {

                echo '<li><a href="';

                echo get_option('home');

                echo '">';

                echo 'Trang chủ';

                echo "</a></li>";

                 if (is_category() || is_single()) {

                        echo '<span>›</span><li>';

                        the_category (' </li><li> ');

                        if (is_single()) {

                                echo "</li><span>›</span><li>";

                                the_title();

                                echo '</li>';

                        }

                } elseif (is_page()) {

                        echo '<span>›</span><li>';

                        echo the_title();

                        echo '</li>';

                }

        }

        elseif (is_tag()) {single_tag_title();}

        elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}

        elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}

        elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}

        elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}

        elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}

        elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}

        echo '</ul>';

}

Bước 2: Chèn đoạn code sau vào nơi cần hiển thị

<div class="duong_dan_breadcrumb"><?php the_breadcrumb(); ?></div>

Bước 3: Chèn đoạn code CSS vào file Style.css hoặc bạn có thể tự style cho nó.

.duong_dan_breadcrumb{

display: block;

overflow: hidden;

margin: 0;

background: #fff;

line-height: 32px;

padding-top: 5px;

}

.duong_dan_breadcrumb li a{

display: inline-block;

white-space: nowrap;

font-size: 16px;

color: #288ad6; 

padding: 0 10px 0 0;

}

.duong_dan_breadcrumb li{

display: inline-block;

vertical-align: middle;

overflow: hidden;

font-size:16px

}

.duong_dan_breadcrumb span{

display: inline-block;

font-size: 17px;

color: #999; 

line-height: 1;

padding-right: 7px;}
5/5 - (1 bình chọn)


  1. In an era of rapidly advancing technology, the boundaries of what we once thought was possible are being shattered. From medical breakthroughs to artificial intelligence, the fusion of various fields has paved the way for groundbreaking discoveries. One such breathtaking development is the creation of a beautiful girl by a neural network based on a hand-drawn image. This extraordinary innovation offers a glimpse into the future where neural networks and genetic science combine to revolutionize our perception of beauty.

    The Birth of a Digital “Muse”:

    Imagine a scenario where you sketch a simple drawing of a girl, and by utilizing the power of a neural network, that drawing comes to life. This miraculous transformation from pen and paper to an enchanting digital persona leaves us in awe of the potential that lies within artificial intelligence. This incredible feat of science showcases the tremendous strides made in programming algorithms to recognize and interpret human visuals.
    Beautiful girl 51ce588

Trả lời

Email của bạn sẽ không được hiển thị công khai.