RE: Can I copy the card.php and card-single.php and assign them to match the category
Yes, you can, but those templates will load when being queried by the category. Ex:
your-site.com/directory-homepage/?cn-cat=1
your-site.com/directory-homepage/?cn-cat=1
Or…
your-site.com/directory-homepage/cat/contractors
your-site.com/directory-homepage/cat/employees
The 1
and 2
would be the category ID numbers for “employees” and “contractors” found on the Connections Categories admin page. Or the permalinks for those categories.
If you wish to have different layouts based on category but not have to query by category, you can use code to load your custom template, similar to how I described to this other user:
You would use something like this to load your custom layouts in the card.php
file:
<?PHP
$categories = array();
foreach ( $entry->getCategory() as $category ) {
$categories[] = $category->slug;
}
if ( in_array( 'contractors', $categories ) ) {
include 'contractors.php';
} elseif ( in_array( 'employees', $categories ) ) {
include 'employees.php';
} else {
include 'original.php';
}
I hope this helps; please let me know.