• I recently designed a shortcode that, when given a link, automatically generates a utm [utm href=””]. My idea was to inject it directly into the “URL” field, but it always adds “http” incorrectly at the beginning, and I haven’t been able to prevent this from happening. I’m somewhat desperate. The shortcode works correctly if I add it using HTML, but it’s not the most practical solution. I would like to be able to use the visual editor.

    • This topic was modified 1 year, 8 months ago by salvadorsru.
    • This topic was modified 1 year, 8 months ago by salvadorsru.
    • This topic was modified 1 year, 8 months ago by salvadorsru.
Viewing 1 replies (of 1 total)
  • You can start a link with # or / which does not add http:

    but you will still end up with href=”#https://www.

    of more precisely href=”#[utm https//abc].

    What you can do is create your own filter for the content

    e.g.

    add_filter( 'the_content', 'my_custom_function', 10 );

    The standard do_shortcode runs at 11 so this will be before shortcode process

    Then my_custom_function simply looks for /[utm or #[utm or indeed https://[utm and pregreplaces to leave just [utm

    then do_shortcode will run at 11

Viewing 1 replies (of 1 total)
  • The topic ‘How to add links without “http” from the visual editor?’ is closed to new replies.