Taxonomies

Visual Portfolio’s custom post type includes custom taxonomies to better organize your projects:

  • Category (slug portfolio_category)
  • Tag (slug portfolio_tag)

You can display these taxonomies on your site using the Block Editor or PHP.

Displaying Taxonomies in Project (Block Editor)

Portfolio Categories Block

You can use the Portfolio Categories block to display categories on Project pages:

Portfolio Tags Block

Similarly, use the Portfolio Tags block to display tags on Project pages:

Displaying Taxonomies in Project (PHP)

To display a list of categories and tags for the current portfolio post, you can use the wp_get_post_terms function in your project templates. Here’s an example:

// Get the portfolio categories list used in the selected portfolio project.
$categories_list = wp_get_post_terms( get_the_ID(), 'portfolio_category' );
var_dump( $categories_list );


// Get the portfolio tags list used in the selected portfolio project.
$tags_list = wp_get_post_terms( get_the_ID(), 'portfolio_tag' );
var_dump( $tags_list );

You can find more functions to work with post taxonomies, such as:

Full List of Portfolio Taxonomies (Block Editor)

To display the list of all available Portfolio Categories or Portfolio Tags, use the Tag Cloud block and select the desired taxonomy in the block settings:

Full List of Portfolio Taxonomies (PHP)

To display a complete list of portfolio categories and tags, use the get_terms function in your PHP templates. Here’s an example:

// Get the full portfolio categories list.
$categories_list = get_terms(
    array(
        'taxonomy'   => 'portfolio_category',
        'hide_empty' => false,
    )
);
var_dump( $categories_list );


// Get the full portfolio tags list.
$tags_list = get_terms(
    array(
        'taxonomy'   => 'portfolio_tag',
        'hide_empty' => false,
    )
);
var_dump( $tags_list );
Was this page helpful?