Support » Plugins » Hacks » How to edit the URL's of the_content(read more) and comments_popup_link?

  • Hi,

    I would like to add google analytics params to the url’s of the_content(read more) and comments_popup_link() function.

    Thus, after the url I would like to add “?utm_source= [..]”

    How can I do this?


Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    You can hook the filter ‘the_content_more_link’ to change the link for read more. There’s no similar filter for popup links, all you can do there is add anchor attributes between class and title with ‘comments_popup_link_attributes’.

    Thanks for the reply!

    The problem is that I’m going to use the output for a newsletter, so I don’t prefer to change WordPress functions. It would be nice if there is another way.

    Is it possible to remove the the_content(read more)-url at all? And then add it manually?

    Maybe this is also possible with the comments-url?

    Moderator bcworkz


    I think you can suppress the content more link by passing an empty string: the_content('');. But this is the link where you can alter the url parms, why do so manually?

    Not sure about popup comments, I don’t use that style. It’s probably initiated from a template file(s?). Doesn’t sound like something you’d want to add manually. You could copy that file(s?) to a child theme and copy from the core file the comments_popup_link() function (with a new name) to the child’s functions.php. Alter your version as needed to include the url parameter and have your child theme template call the altered function instead of the core.

    Or maybe a different analytics trigger would be easier to implement? I know little of the actual analytics mechanics, as you might be able to tell.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to edit the URL's of the_content(read more) and comments_popup_link?’ is closed to new replies.