How can you create a class specifically for Taxonomy?

So I am trying to have a class for my taxonomy.blade.php page. What should the file name on Controllers be if you are doing a class on taxonomy.php on sage?

right now there is a fatal error, the way i tried naming in Controllers was (Taxonomy.php, TaxonomyPage.php) but no luck. This is what i have on my taxonomy Taxonomy Controller so far.

    <?php



namespace App\Controllers;

use Sober\Controller\Controller;


class TaxonomyPage extends Con    troller
    {
        public function locations()
        {
            $args =[
                'post_per_page' => -1,
                'offset' => 0,
                'orderby' => 'date',
                'order' => 'ASC',
                'post_type' => 'locations'
            ];

        $the_query = new \WP_Query($args);
        $locations = [];
        if($the_query->post_count > 0)
        {
            $locations = array_map(function ($locations){


                $url = get_permalink($locations);
                $street_address = get_field('street_address', $locations);
                $city = get_field('city', $locations);
                $state = get_field('state', $locations);
                $zip_code = get_field('zip_code', $locations);
                $image = get_field('picture' , $locations);
                $picture = $image['sizes']['medium'];
                $alt = $image['alt'];
                $site_url = get_field('site_url');



                return (object)[
                    'url' => $url,
                    'street_address' => $street_address,
                    'city' => $city,
                    'state' => $state,
                    'zip_code' => $zip_code,
                    'picture' => $picture,
                    'site_url' => $site_url,
                    'alt' => $alt
                ];

            }, $the_query->posts);

            wp_reset_postdata();
        }
        return $locations;
    }

}

What is the error? It’s difficult to debug without knowing what the system thinks is wrong.

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