NO BUG: Can't wrap content in a link

I am trying to make a repeatable card in which I want the whole card to link to the post.
If i change the tag wrap of the main parent div to link with {post_url} variable, it breaks the loop

If i add a sub div or block and set that to link, the div fails to wrap around the child element.

Ie instead of the expected

<div>   --looped
<a href= {post_url}>
<h1>heading </h1> <p>CONTENT</p>
 </a>
<div>

Or

<a href= {post_url}>  --looped
<div>

<h1>heading </h1> <p>CONTENT</p>
 <div>
</a>

It ends up rending as:

<div>
<a href= {post_url}>
</a> 
<h1>heading </h1>
 <p>CONTENT</p> </div>

Which prevents the clickable card as there is nothing to click

What am I doing wrong? I don’t see a gap.

Hi Jon,
Thanks so much for your report!

This sounds suspiciously like the “link within a link” problem. Links within links are not allowed. Just have a look at the source code to see if there are two links.

Having a live link, I could tell you directly :slight_smile:

Best regards,
timmse

I did have the header tag wrapped in a link before deciding i wanted the whole card. Ill check to see if that is the problem in a bit.

If so, it might be helpful to have some sort of warning message for such occurrences, or have a dedicated link wrapper in the structure panel

So, I removed the link from the header. If i put a link tag on the looped item, it breaks the inner parts

Adding a child div, does work, but creates a separate link around each child element

I also have the labels in a rich text editor like this, so i am not sure why the job type (which is a taxonomy) is having a link added when I only want it to be text, though I may change my mind and want it filterable in the future when you all add that capability. But for now, who is telling it to be a link?

image

The post terms are rendered as a link by default, leading to the link inside a link issue.
To simply show the term but not link to it, you can use the :plain filter:

{post_terms_job-type:plain}

Alright, that solved the issue. Thanks. They need to make that more apparent that a link is auto added, cause it makes troubleshooting a problem difficult when there is no reason I would have thought a plain text variable would have included a link.

This is one reason why I dislike WordPress. No actual code to review and edit. Things just happen.

You’re welcome.

In most cases, you want to link to the category or tag, so this is the default. If you look at the code (dev tools) or click on it in the front end, you will see that it is a link, so there are at least two ways to “review” :wink: