-2

I want to keep an image link to just the image, but it runs on to the adjacent text. I have an image that I attached a link to and made it into a shortcode:

function data_integrity(){
return '<a target="_blank" href="https://openforestry.org/validity-integrity"> <img style="float: right; margin: 0px 10px 10px 10px;" src="https://openforestry.org/wp-content/uploads/2017/08/data_integrity.png" </a>';
}
add_shortcode('shield', 'data_integrity');

I'm adding it to posts via the shortcode [shield]. However, whatever text comes after that shortcode is also linked to the same page as the image. How can I force an end to the link in the shortcode or in the post content? Here's an example where the text under the Summary heading is also linked, but I don't want it to be. Sample of run-on link from image

I've tried to wrap the shortcode in a div, but that did nothing - the link continues to run into the adjacent text.

The post content is currently:

[shield] Michele Garfinkel of the European Molecular Biology Organization...

I want to keep the layout where the image and text are aligned, but break the HTML link so that the text is just plaintext.

  • 1
    You forgot the </a>! – FluffyKitten Sep 28 '17 at 20:30
  • Right! Added it, still running over. – Adam Costanza Sep 28 '17 at 20:43
  • 1
    Now you've forgotten to close your image tag: return '<a target="_blank" href="[...]"> <img style="[...]" src="[...]" </a>'; should be return '<a target="_blank" href="[...]"> <img style="[...]" src="[...]"> </a>'; – FluffyKitten Sep 28 '17 at 20:47
1

You forgot the image tag as well...

return '<a target="_blank" href="https://openforestry.org/validity-integrity"> <img style="float: right; margin: 0px 10px 10px 10px;" src="https://openforestry.org/wp-content/uploads/2017/08/data_integrity.png"> </a>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.