Skip Navigation

[Resolved] link appearing multiple times on frontend

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user had this code here

<a href="[wpv-post-url]">
<div class="search-resource-single">
  <div class="search-resource-single-inner">
      <div class="search-resource-single-inner-top">
                 [wpv-conditional if="( $(edd_price) gt '0' )"]
        <p class="search-resource-price-tag">[wpv-post-field name='edd_price']</p>
            [/wpv-conditional]
            [wpv-conditional if="( $(edd_price) eq '0' )"]
        <p class="search-resource-price-tag">Free</p>
[/wpv-conditional]
    </div>
      <div class="search-resource-single-inner-bottom">
[wpv-view name="module-terms-view"] 
        <h3 class="search-resource-single-title">[wpv-post-title]</h3>
        <p class="search-resource-single-age">[wpv-post-taxonomy type="age-category" separator=" "] <span class="search-resource-single-type"> [types field='resource-type'][/types]</span></p>
</div>
  </div>      
</div>
</a>

However his link was being rendered multiple times even though it should only be there once.
Solution:

This was actually caused by the [wpv-post-taxonomy type="age-category" separator=" "] Shortcodes as it is rendering the taxonomy terms as links which breaks the wrapping a tag.

To resolve this just change the format of the taxonomy output from a link to just the name.
[wpv-post-taxonomy type="age-category" separator=" " format='name']

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 13 replies, has 2 voices.

Last updated by davidR-12 6 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1099660

I have a page here:

hidden link

password: Europa-808

You can see the 3 blocks to the right of "Helping you teach the tough stuff". These are created with a content template that is part of a view. The code for the content template is:

<a href="[wpv-post-url]">
<div class="search-resource-single">
  <div class="search-resource-single-inner">
      <div class="search-resource-single-inner-top">
                 [wpv-conditional if="( $(edd_price) gt '0' )"]
        <p class="search-resource-price-tag">[wpv-post-field name='edd_price']</p>
            [/wpv-conditional]
            [wpv-conditional if="( $(edd_price) eq '0' )"]
        <p class="search-resource-price-tag">Free</p>
[/wpv-conditional]
    </div>
      <div class="search-resource-single-inner-bottom">
[wpv-view name="module-terms-view"] 
        <h3 class="search-resource-single-title">[wpv-post-title]</h3>
        <p class="search-resource-single-age">[wpv-post-taxonomy type="age-category" separator=" "] <span class="search-resource-single-type"> [types field='resource-type'][/types]</span></p>
</div>
  </div>      
</div>
</a>

But if you look at the code on the frontend you can see the link tags that contain the rest of the code are being created 5 times instead of once. Can you tell me why this is please?

Regards,

David

#1099703

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screen Shot 2018-09-04 at 3.11.30 PM.png

Hi David,

Thank you for contacting our support forum.

I'm actually seeing this created 4 times instead of 5 and it could be because of the last index shortcode on your view that adds the extra div.

So far what I can see is actually normal. Can you send me a screenshot where you see 5 ? See My Screenshot

Thanks,
Shane

#1100378
Capture.JPG

Hoi Shane,

I have added a screenshot. You can see the a tag

<a href="<em><u>hidden link</u></em>">

is added at the top as it should do but then is also being placed throughout the HTML

regards,

david

#1100653

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

Ah yes I see what you mean now. There isn't a single A tag, but multiple a tags spanning the entire div.

I suspect that this is caused by the multiple divs .

Try using this [wpv-post-url output='raw']

Let me know if this helps.
Thanks,
Shane

#1101375

Hi Shane,

I tried that but am still getting the same issue.

Regards,

David

#1101674

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

Would you mind providing me with access so that I can help debug this issue better?

Thanks,
Shane

#1101821

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

So the issue is pretty much with this shortcode [wpv-post-taxonomy type="age-category" separator=" " ]

The post taxonomy shortcode is generating an anchor tag for each taxonomy term. This is why you are experiencing this issue because of an A tag within an A tag.

What i've done currently is to set it to display only the taxonomy name without the link using the format='name' attribute.

Thanks,
Shane

#1102354

Hi Shane,

Thanks for identifying the issue and fixing the link problem. However, I need to be able to style the individual terms to have black backgrounds etc. I cant see a way to do this with 'name' as there are no tags for me to use (I actually didnt need the a tags around them originally but used them as a way to target them for styling). Is there a solution here?

Regards,

David

#1102534

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

You should be able to do it like this.

[wpv-post-taxonomy type="age-category" separator="<p class='test'>" format='name' class='test']

This will list each item in a p tag with the class test.

You should be able to style this now.

Thanks,
Shane

#1102539

H Shane,

That doesnt work. The first term is ignored as it comes after the first seperator and the third term doesnt have its p tag closed until after another unrelated element.

David

#1102550

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

I see what you mean.

This is actually intentional where the first Item doesn't get the p tag. Its because this is meant to be a separator .

You will probably need to style them using the 2 different classes .

The search-resource-single-age class and the test class.

Thanks,
Shane

#1102555

Hi Shane,

But search-resource-single-age is not relevant as its just a containing class (Ive actually removed it as its not doing anything. ) The current code is :

[wpv-post-taxonomy type="age-category" separator="<p class='test'>" format='name'] 

But I still have the same issue that only the middle term is usefully being wrapped in the 'test' class.

David

#1102666

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

Not sure what else we can do about this as some compromised solution would need to be used.

The reason is because separator will not appear on the first item since we are pretty much using the separator as a workaround to wrap the items.

So i'm really not sure what else can be done.

Thanks,
Shane

#1105558

Thanks Shane. It would be great to have the option to wrap each term in a chosen tag. I used a custom taxonomy view to solve the issue, but its annoying to have to replicate the functionality of a shortcode with a whole view.

David