• I’m trying to add a simple query string to track news stories. The problem is that each time, the ?” or “#” is removed from the URL. How do I add a query string that will remain in the final URL?

    My goal is to have a URL like this: mydomain.com/post-name/?source=”news-site”

    Any suggestions?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The easiest way is to search using the query you want to use from the search box (if your theme provides that). The resulting URL can be copied from the browser bar and then used as a link within your site or added to a menu item to ‘channel’ search results for your visitors.

    You can also add this to a URL to make a search page…

    /?s=tree

    Replace the word ‘tree’ with your search term!

    See also…

    https://codex.www.ads-software.com/Creating_a_Search_Page

    Hope this helps.

    • This reply was modified 4 years, 7 months ago by JNashHawkins.

    Not sure but have to seen the add_query_arg() function?

    Like to you want to keep the same URL with query string then use the following codes to generate the URL:

    
    # output - https://mydomain.com/post-name?foo=bar
    echo add_query_arg(
        'source',
        'news-site',
        'https://mydomain.com/post-name'
    );
    

    Take a look at the WordPress documentation and the source from where I copied the codes.
    https://wphuntrz.com/d/44-how-to-add-query-string-to-permalink

    I hope this helps.

    Thread Starter tompkinsjournal

    (@tompkinsjournal)

    I’m aware of add_query_arg() but haven’t seen a working example (I’m more of a content person) to emulate. I’d like to be able to accomplish this through the back-end (submitting it to a custom URL or a redirect plugin.

    Thanks for the lead.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Add Query String to Permalink?’ is closed to new replies.