You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Learndash自定义分类模板命名问题求助

Fixing Custom Taxonomy Template Not Working for LearnDash Course Categories

Hey there! Let's troubleshoot why your taxonomy-course-category.php template isn't kicking in for your LearnDash course category page (http://example.com/course-category/photoshop/). The most common culprit here is a mismatch between the taxonomy slug you're targeting and what LearnDash actually uses under the hood.

Step 1: Verify the Actual LearnDash Course Category Taxonomy Slug

LearnDash doesn't use course-category as the official taxonomy slug for its course categories—instead, it defaults to ld_course_category. To confirm this:

  • Add a quick debug snippet to your theme's functions.php file (or temporarily add it to a generic template like archive.php):
    <?php
    if (is_tax()) {
        $tax_obj = get_queried_object();
        var_dump($tax_obj->taxonomy); // This will print the actual taxonomy slug
    }
    ?>
    
  • Visit your course category page, and you'll see the taxonomy slug is ld_course_category, not course-category.

Step 2: Rename Your Template File Correctly

Once you confirm the taxonomy slug, rename your template to match:

  • For all course category pages: Use taxonomy-ld_course_category.php
  • For the specific "photoshop" category only: Use taxonomy-ld_course_category-photoshop.php

Step 3: Rule Out Other Potential Issues

If the template still isn't working after renaming, check these:

  • File Location: Ensure the template is placed directly in your active theme (or child theme) root directory—not in a subfolder like /templates/ unless your theme explicitly supports that structure.
  • Cache: Clear your WordPress cache, browser cache, and any server-level cache (like Cloudflare or WP Rocket) to make sure the new template is loaded instead of cached old files.
  • Template Hierarchy Priority: Confirm your theme doesn't have a higher-priority template (like archive.php) that's overriding your taxonomy template. WordPress prioritizes taxonomy-{taxonomy}.php over generic archive templates, so this is less likely, but worth double-checking.

Once you fix the template filename to match LearnDash's actual taxonomy slug, your custom template should load as expected!

内容的提问来源于stack exchange,提问作者Ehsan Musavi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:00:07