I keep finding tutorials on listing all the slugs on the internet but can't seem a function or line of code that can echo/return me the slug of the category i'm on so I can save it on a variable.
Does anyone know what it is? I need to be able to use it in archive-product.php
Thanks in advance
$slugs = array();
foreach( (get_the_category()) as $category ) {
array_push( $slugs, $category->slug );
}
var_dump( $slugs );
(untested)
http://codex.wordpress.org/Function_Reference/get_the_category
Edit:
Tested and works correctly. Try adding to archive.php (temporarily) and make sure your url is something like: mysite.com/category/uncategorized/
. I suspect you may not be calling the correct template file or perhaps not actually browsing any categories.