Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1326299

    Hi Support

    Is it possible to display the categories and tags of a portfolio or a Custom Post Type directly in each portfolio page (single page).
    I found a function that allows you to deploy a shortcode but it is from 2015 and Enfold must have evolved because it doesn’t work anymore.
    Thanks for your help!

    function show_portfolio_category_func($atts) {
    	$atts = shortcode_atts( array(
            'id' => '',
    	), $atts, 'portfolio_category' );
    
    	global $post;
    	$the_terms = get_the_terms( $post->ID , 'portfolio_entries');
    	$output = '';
    	foreach($the_terms as $term) {
    		if($term->parent == $atts['id']) {
    			$termlink = get_term_link($term->term_id, $term->taxonomy);
    			$output .= '<span class="portfolio_cat"><a href='.$termlink.'>'.$term->name.' </a></span>';
    		}
    	}
        return $output;
    }
    add_shortcode('portfolio_category', 'show_portfolio_category_func');
    #1326305

    Hey Ikyo,

    Thank you for the inquiry.

    The shortcode above should still work in the latest version. But it will only show child categories and you have to provide the ID of the parent term or category. Did you use the “portfolio_category” shortcode in a text or code block?

    [portfolio_category id="ID-OF-THE-PARENT-CATEGORY"]
    

    If you want to display all categories, replace the shortcode snippet with the following code.

    function show_portfolio_category_func($atts) {
    	global $post;
    	$the_terms = get_the_terms( $post->ID , 'portfolio_entries');
    	$output = '';
    	foreach($the_terms as $term) {
    		$termlink = get_term_link($term->term_id, $term->taxonomy);
    		$output .= '<span class="portfolio_cat"><a href='.$termlink.'>'.$term->name.' </a></span>';
    	}
        return $output;
    }
    add_shortcode('portfolio_category', 'show_portfolio_category_func');

    Best regards,
    Ismael

    #1326523

    many thanks Ismael !
    I use the block code to prevent any additional html formatting.

    I will test this shortcode
    Kind regards

    #1326647

    Hi,

    No problem! Please let us know if the shortcode works. We will keep the thread open.

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.