Monthly Archives: February 2015

Taxonomy Breadcrumbs

Add this function to the functions.php file in your current theme:

/* Taxonomy Breadcrumb */
function id_taxonomy_breadcrumb() {
// Get the current term
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
// Create a list of all the term's parents
$parent = $term->parent;
while ($parent):
$parents[] = $parent;
$new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
$parent = $new_parent->parent;
endwhile;
if(!empty($parents)):
$parents = array_reverse($parents);
// For each parent, create a breadcrumb item
foreach ($parents as $parent):
$item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
$url = get_bloginfo('url').'/'.$item->taxonomy.'/'.$item->slug;
echo '<a href="'.$url.'">'.$item->name.'</a> / ';
endforeach;
endif;
// Display the current term in the breadcrumb
echo $term->name;
}

And the call it in the temlate:

<?php id_taxonomy_breadcrumb(); ?>

Set WordPress permissions recursively with CLI in Linux

To easily change the permissions, just navigate to the WordPress install folder, and execute this two commands:

#Set all directories recursively to 755:
find . -type d -exec chmod 0755 {} +

#Set all files recursively to 644:
find . -type f -exec chmod 0644 {} +

If you are not in the current directory you will need to add the desired one after find, something like:

find /top/path/here -type d -exec chown www-data:www-data {} \;