It seems like you are trying to get a term by it’s slug or name. get_term()
will get all the term’s data by it’s id. In this case, use get_term_by()
instead:
function product_category_button($atts) {
extract(shortcode_atts(array(
'category' => '',
), $atts));
// if( $category ) :
// Vars
$taxonomy = 'product_categories';
// Use 'name' instead of 'slug' if you want to get the term by it's name
$term = get_term_by( 'slug' , $category, $taxonomy ); //$post->ID
$cat = $term->name;
$parent = $term->parent;
var_dump($cat);
if ($parent == NULL) :
// Vars
$link = get_term_link( $term->slug, $taxonomy);
$html_out="";
$html_out .= '<a class="x-btn x-btn-primary x-btn-global hvr-bounce-to-bottom" href="' . $link . '">' . 'See All Products' . $cat . '</a>';
endif;
return $html_out;
// endif;
}
add_shortcode( 'see_all_products', 'product_category_button' );
For further reading, take a look into codex.