Tagged: portfolio tags, Tags
-
AuthorPosts
-
August 21, 2018 at 10:46 pm #1000071
I am using this code to show show tags through a shortcode on my portfolio items, to help with SEO:
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 .= '<span class="portfolio_tag"><a href='.$taglink.'>'.$tag->name.' </a></span>'; } return $output; } add_shortcode('portfolio_tags', 'show_portfolio_tags_func');
It’s working fine, but the tags are very close together – see https://imgur.com/a/N6Rsbmi
and the links that are attached to them do not lead to a list/gallery of items for that tag, but back to the same page.
Can you help me with this?
thanks very much
NancyAugust 22, 2018 at 1:13 pm #1000295Hey Munford,
Here is the code you can put in Enfold > General Styling > Quick Css, if it does not work, put into themes/enfold/css/custom.css
.portfolio_tag { margin-right: 10px; }
If you need further assistance please let us know.
Best regards,
VictoriaAugust 22, 2018 at 2:44 pm #1000361Hi VIctorica
thanks for the help! Is it possible to put a “/” between the tags as well?Can you also look at the 2nd issue – the links that are attached to the tags do not lead to a list/gallery of items for that tag, but back to the same page. I don’t think that’s how it’s supposed to work, right? Is there something wrong in the function code above?
Best
Nancy- This reply was modified 6 years, 2 months ago by Munford.
August 24, 2018 at 10:47 am #1001106Hi Nancy,
Please try the code like this:
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 .= '<span class="portfolio_tag"><a href='.$taglink.'>'.$tag->name.'/</a></span>'; } rtrim($output, '/'); return $output; } add_shortcode('portfolio_tags', 'show_portfolio_tags_func');
If you need further assistance please let us know.
Best regards,
VictoriaAugust 24, 2018 at 10:54 am #1001108Hi victoria,
thanks- but that code is giving me this error on this line:
$the_tags = get_the_tags( $post->ID , ‘portfolio_entries’);
the & is in the code for the > ($the_tags = get_the_tags( $post->ID , ‘portfolio_entries’);)Your PHP code changes were rolled back due to an error on line 109 of file wp-content/themes/enfold-child/functions.php. Please fix and try saving again.
syntax error, unexpected ‘&’
is there something wrong in the code?
thanks for your help
Nancy- This reply was modified 6 years, 2 months ago by Munford.
August 24, 2018 at 2:37 pm #1001253Hi Nancy,
Try it like this:
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 .= '<span class="portfolio_tag"><a href='.$taglink.'>'.$tag->name.'\/</a></span>'; } rtrim($output, '/'); return $output; } add_shortcode('portfolio_tags', 'show_portfolio_tags_func');
Best regards,
VictoriaAugust 24, 2018 at 3:15 pm #1001270Hi again
That looks better but the links are still not working correctly – they are all leading back to the same page instead of to the tag categories.
Can you please check it?
Thanks for your help
Nancy- This reply was modified 6 years, 2 months ago by Munford.
August 25, 2018 at 11:44 am #1001595Hey Nancy!
You need to check what you’re getting in the $taglink variable here.
Cheers!
VictoriaAugust 25, 2018 at 1:25 pm #1001632I don’t write code and don’t understand what that means. All the tags are link back to the parent page right now. They should lead to the different tag categories.
I looked at another thread https://kriesi.at/support/topic/tags-in-portfolio-dont-link-to-corresponding-tag-archive/#post-840434 which gave this code instead of the one you gave me for the portfolio tags for someone having the same problem.
function avs_show_portfolio_tags_func() { global $post; $the_tags = get_the_tags( $post->ID ); $output = ''; foreach($the_tags as $tag) { $taglink = get_tag_link($tag->term_id); $output .= '<span class="portfolio_tag"><a href='.$taglink.'>'.$tag->name.' </a></span>'; } return $output; } add_shortcode('portfolio_tags', 'avs_show_portfolio_tags_func');
It seems to work – as it links to the portfolio tags now – but there are no items coming up on those pages. Can you check this please on the page below?
thanks
Nancy- This reply was modified 6 years, 2 months ago by Munford.
August 26, 2018 at 8:40 am #1001825Hi,
I think we solved this with: https://kriesi.at/support/topic/portfolio-tags-linking-error-tag-placement/#post-1001776
Best regards,
DudeAugust 26, 2018 at 12:30 pm #1001851yes you did, thanks so much! you can close this thread
August 26, 2018 at 12:53 pm #1001857Hi,
Great, glad it works now :)
Best regards,
Dude -
AuthorPosts
- The topic ‘portfolio tags styling, links’ is closed to new replies.