Controller for custom taxonomy not working

Hi

So I have a custom taxonomy: maintenance_package

I am using the following blade template which is working fine…

taxonomy-maintenance_package.blade.php

For bug fixing this issue, it just has this code in it…

@extends('layouts.app')

@section('content')
    {{ $testing_controller }}
@endsection

What I cant seem to do is get a controller working with the template.

My assumption was that it would be named this…

TaxonomyMaintenancePackage.php

And its contents would be this…

<?php

namespace App\Controllers;

use Sober\Controller\Controller;

class TaxonomyMaintenancePackage extends Controller
{
    public function TestingController()
    {
        return 'Hello World';
    }
}

** I have also tried it as a static function which also doesn’t work

The error I am getting is…

Notice: Undefined variable: testing_controller in /Path/To/My/Cache...

I have tried these class/controller file naming structures with no joy…

  • Taxonomy_Maintenance_Package
  • TaxonomyMaintenance_Package
  • MaintenancePackage

Additional info…

Im using Sage v9.0.9

The taxonomy is created using the plugin below and uses underscores between its naming of the slug which I thought might be an issue maybe? possibly?

Any help would be gratefully received… :slight_smile:

You can use a debug plugin like Query Monitor or Debug Bar to show a list of all attempted template paths for a taxonomy:

https://wordpress.org/plugins/debug-bar/

Related issue:
https://discourse.roots.io/t/sage-9-taxonomy-template/18620/4

This topic was automatically closed after 42 days. New replies are no longer allowed.