-1
function ls_de_options($content) {
            return '<h3><a href="www.google.com">Hello World</a></h3>'.$content;

        }
add_filter( 'the_content', 'ls_de_options' );

The link does not work. It is taking me to http://example.com/www.google.com

What I wanted to do was to put a share button link to every post in my blog Or is there a better way to add share button.

1

1 Answer 1

1

The reason the link isn't working is because you haven't formatted it correctly.

This:

return '<h3><a href="www.google.com">Hello World</a></h3>'.$content;

Should be this:

return '<h3><a href="https://www.google.com/">Hello World</a></h3>'.$content;

To answer your other question: There are a lot of social sharing plugins that will add sharing links to your content.

2
  • Not best practice to print links in WordPress using your method James and Puni. Jun 27, 2015 at 14:48
  • Brad whats your suggestion
    – Puni
    Jun 27, 2015 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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