傻大憨

wordpress子分类调用父分类名称和链接

专为导航而生,在wordpress模板制作过程中常常会在做breadcrumbs导航时会用到,子分类调用父分类的名称和链接,下面这段简洁的代码,可以完美解决这个问题。

<?php echo get_category_parents( $cat, true, ' &raquo; ' ); ?>

下面这种方法也可以,不过代码不够简洁。

<?php
if ( is_category() ) {
    // Get the current category term id.
    $query_obj = get_queried_object();
    $term_id   = $query_obj->term_id;
 
    echo get_term_parents_list( $term_id, 'category' );
}
?>

第三种方法,调用分类目录名称和链接,作为导航。

<?php
if ( ( is_tax() || is_category() || is_tag() ) ) {
    $trail     = '';
    $home      = '/<a href="' . get_home_url() . '">Home</a>';
    $query_obj = get_queried_object();
    $term_id   = $query_obj->term_id;
    $taxonomy  = get_taxonomy( $query_obj->taxonomy );
 
    if ( $term_id && $taxonomy ) {
        // Add taxonomy label name to the trail.
       // $trail .=  '/' . $taxonomy->labels->menu_name;
        // Add term parents to the trail.
        $trail .= '/' . get_term_parents_list( $term_id, $taxonomy->name, array( 'inclusive' => false ) );
    }
 
    // Print trail and add current term name at the end.
    echo '<p class="breadcrumb-trail">' . $home . $trail . $query_obj->name . '</p>';
}
?>
Published
Categorized as 建站知识 Tagged ,

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

一个数据库中安装多个wordpress网站的方法

如果你在建站时,需要在一个数据库中安装多个wordpress网站,只要不与已经建立的数据表前缀一样就可以。

外贸B2C独立站与外贸B2B独立站有什么区别

简站wordpress资深运营赵经理认为,在外贸领域中,企业应根据自身业务特点和目标市场需求,选择合适的独立站模式进行搭建和运营。

WordPress外贸建站从初级到高级的学习之路

  WordPress外贸建站教程提供了一个全面而系统的学习路径,从初级到高级的阶梯式学习让每位学员能够轻松掌… Continue reading WordPress外贸建站从初级到高级的学习之路

Jianzhanpress WordPress Theme is a professional WordPress website building service provider

The best Chinese WordPress service provider

建B2B独立站WordPress主题怎么选

B2B独立站的核心是高效展示产品与获取免费流量——这包含传统搜索引擎的SEO免费流量,也包括来自ChatGPT、DeepSeek、豆包等AI平台通过GEO带来的新型免费流量。选择主题时,重点考察三点:是否能清晰美观地展示产品、是否拥有良好的SEO基础架构、内容结构是否便于AI收录和引用。

WordPress主题中添加自定义Owl Carousel轮播

首先,您需要在WordPress主题中安装Owl Carousel组件。可以通过WordPress主题文件目录安装Owl Carousel。