Case study: How to show only the related tags and portfolio categories – Enfold theme
Ticket to the Enfold Support Team #1153473
by using tag cloud widget area
Avia Builder Element
Case
1. I would like to have an option in Tag Cloud Widget, where you could choose to display “all” or “related” tags and/or categories, when added to a single portfolio/blog.
2. How to show only the related tags/portfolio categories?
Test
I created two Enfold Child Custom Widget Areas: tags and portfolio categories. As you could see:
- the widget area shows all the available tags(5) / categories(4)
- and there are only 3 tags and 2 categories related to the page
Tags
Portfolio Categories
by using short codes
Short codes are pasted to a Text Avia Builder Element
Request
3. How to show only the related tags/portfolio categories?
4. How to have the same design as the widget area?
Test
I added two shortcodes: portfolio_tags and portfolio_category. As you could see in tests 1, 2, 3.
In order to have related tags and portfolio categories, I researched for similar topics in the Enfold Support Forum.
1. Tags & Portfolio Categories
I started by following the instructions in:
Enfold Support Ticket #673578
function show_portfolio_category_func() {
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 .= ''.$term->name.' ';
}
return $output;
}
add_shortcode('portfolio_category', 'show_portfolio_category_func');
Result
a) It shows only the related categories – OK
b) Clickable – OK
c) Design – NOK
*The snippet is currently commented (functions.php).
2. Portfolio categories
The first ticket (#673578) refers to another snippet:
Enfold Support Ticket #540059
function show_portfolio_category_func() { global $post; $the_terms = get_the_terms( $post->ID , 'portfolio_entries'); ob_start(); echo $the_terms[0]->name; $output = ob_get_clean(); return $output; } add_shortcode('portfolio_category', 'show_portfolio_category_func');
Result
a) It shows only the Primary category – NOK
b) Non-clickable – NOK
c) Design – NOK
*The snippet is currently active (functions.php)
3. Tags
In order to have related tags, I followed the instructions here:
Enfold Support Ticket #813872
function show_portfolio_tags_func() {
global $post;
$the_tags = get_the_tags( $post->ID , 'portfolio_entries');
$output = '';
foreach($the_tags as $tag) {
$taglink = get_tag_link($tag->tag_id);
$output .= ''.$tag->name.' ';
}
return $output;
}
add_shortcode('portfolio_tags', 'show_portfolio_tags_func');
Result
a) It shows only the related tags – OK
b) Clickable – OK
d) Design – NOK
*The snippet is currently commented (functions.php).
Summary
Case study: How to show only the related tags and portfolio categories – Enfold theme
The initial need came from portfolio posts. The only option I found was using a custom widget area. Then my online research led me to the 3 solutions that work partially.
Test 1 and 3 (see above) have the needed functionality, BUT not a good design. Elements have to be separated.
Enfold Support Answer:
The Tag Cloud widget is not from the theme. It is a default WP widget, so the changes that you’re after will require modifications that are beyond the scope of support. The easiest solution is to find a plugin that will satisfy these requirements. Or hire someone else to add the feature or modification for you.See more in my Enfold Support Ticket #1153473
Hey, there!
This is my first case study article. Give it a boost by sharing it.
10x