New/custom templates in Sage 9

I’m using Sage 9 beta3 for building up a new web project.
I need to setup custom posts and taxonomies including custom tags and categories. For them I need to create individual templates to output the post items.
Looking at Sage 9 documentation I’m not sure about the current state of each *.md file. I found a note that the documentation is in progress right now. But looking at some sections they seems to be up-to-date and some of them note (maybe).

Can someone give me a hint where to place a new template for a custom taxonomy and for a custom post type. I need the concrete location and the filename (syntax).

Hi Daniel, welcome to Roots Discourse!

What have you tried?

1 Like

Thanks for your response!

I tried to place additional templates into this directory:
/wp-content/themes/<themename>/resources/views

Example:

  1. I added a custom post type with the name job
  2. I added custom taxonomies with the names jobcategories and jobtags
  3. I added a “taxonomy” template inside the the directory path above with the name taxonomy-jobcategories.blade.php

Request now <host>/?taxonomy_name=jobcategories I get some posts (type: custom post: job from no. 1) served from the template front-page.blade.php. If I try <host>/jobcategories/ I get a 404 served by 404.blade.php

How did you add the taxonomy? What is public set to in the taxonomy registration?

Have you re-saved your permalinks?

Here the code for the taxonomy:

function job_taxonomies() {
	$labels = array(
		'name'              => _x('Job Categories', 'taxonomy general name', 'textdomain'),
		'singular_name'     => _x('Job Category', 'taxonomy singular name', 'textdomain'),
		'search_items'      => __('Search Job Categories', 'textdomain'),
		'all_items'         => __('All Job Categories', 'textdomain'),
		'parent_item'       => __('Parent Job Category', 'textdomain'),
		'parent_item_colon' => __('Parent Job Category:', 'textdomain'),
		'edit_item'         => __('Edit Job Category', 'textdomain'),
		'update_item'       => __('Update Job Category', 'textdomain'),
		'add_new_item'      => __('Add New Job Category', 'textdomain'),
		'new_item_name'     => __('New Job Category Name', 'textdomain'),
		'menu_name'         => __('Job Category', 'textdomain'),
	);
	$args = array(
		'hierarchical'      => true,
		'labels'            => $labels,
		'show_ui'           => true,
		'show_admin_column' => true,
		'query_var'         => true,
        'public'             => true,
        'publicly_queryable' => true,
		'rewrite'           => array('slug' => 'jobcategories'),
	);

	register_taxonomy('jobcategories', array('job'), $args);

    $labels = array(
		'name'              => _x('Job Tags', 'taxonomy general name', 'textdomain'),
		'singular_name'     => _x('Job Tag', 'taxonomy singular name', 'textdomain'),
		'search_items'      => __('Search Job Tags', 'textdomain'),
		'popular_items'     => __('Popular Job Tags', 'textdomain'),
		'all_items'         => __('All job tags', 'textdomain'),
		'parent_item'       => null,
		'parent_item_colon' => null,
		'edit_item'         => __('Edit Job Tags', 'textdomain'),
		'update_item'       => __('Update Job Tag', 'textdomain'),
		'add_new_item'      => __('Add New Job Tag', 'textdomain'),
		'new_item_name'     => __('New Job Tag Name', 'textdomain'),
		'separate_items_with_commas' => __('Separate tags with commas', 'textdomain'),
		'add_or_remove_items' => __('Add or remove job tags', 'textdomain'),
		'choose_from_most_used' => __('Choose from the most used job tags', 'textdomain'),
		'not_found'         => __('No job tags found.', 'textdomain'),
		'menu_name'         => __('Job Tags', 'textdomain'),
	);

	$args = array(
		'hierarchical'      => false,
		'labels'            => $labels,
		'show_ui'           => true,
		'show_admin_column' => true,
		'update_count_callback' => '_update_post_term_count',
		'query_var'         => true,
        'public'             => true,
        'publicly_queryable' => true,
		'rewrite'           => array('slug' => 'jobtags'),
	);

	register_taxonomy('jobtags', array('job'), $args);
}

I also re-saved the permalinks.

Outcome 1:
For the permalinks I need to change the url to: <host>/jobcategories/<term>/ after that I get a view served from taxonomy-jobcategories.blade.php.
The 404 use-case described above is solved.