Tag: url

  • How to add a protocol to URLs from WordPress post content

    How to add a protocol to URLs from WordPress post content

    Sometimes you have URLs without http:// OR https:// into WordPress post content.

    So you can use the following function for that. You can use this function for the_content filter for WP. And also you can use this anywhere in PHP code other than WP.

    https://gist.github.com/BhargavBhandari90/67489aad26967f6afe2d6e52f278cc99
  • Change URL without reloading page using Javascript

    Change URL without reloading page using Javascript

    This will be possible if your browser supports HTML5. You can do that by below small code.

    var title = 'Your Title',
        url   = 'https://yoursite.url';
    if (typeof (history.pushState) != "undefined") {
        var obj = { Title: title, Url: url };
        history.pushState(obj, obj.Title, obj.Url);
    }

    You can remove a title from the object ( `obj` ) if you don’t want to change the page title. In that case, the second parameter in pushstate function will be blank. like below:

    history.pushState(obj, '', obj.Url);

    That’s it