Without knowing exactly what you are trying to do, it seems you want to append query variables to the URL. WordPress has methods for handling that properly, without manual string concatenation.
Look at the documentation for add_query_arg()
for details:
https://developer.wordpress.org/reference/functions/add_query_arg/
You can rebuild the URL and append query variables to the URL query by using this function. There are two ways to use this function; either a single key and value, or an associative array.
Using a single key and value:
add_query_arg( 'key', 'value', 'http://example.com' );
Would create http://example.com/?key=value
Using an associative array:
add_query_arg( array(
'key1' => 'value1',
'key2' => 'value2',
), 'http://example.com' );
This would create http://example.com/?key1=value1&key2=value2
Related Posts:
- Dynamic URL to reference custom PHP files
- Remove query string specific key value
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Removing all my hardcoded URLs with get_site_url()
- How to get URL of current page displayed?
- Encode text string being appended as query to URL [closed]
- Is it safe to use $_SERVER[‘REQUEST_URI’]?
- The correct method to pass query vars in AJAX using ajaxurl
- How to check if feed URL was requested?
- What is the best practice for escaping data URIs?
- urlencoding of the_title() doesn’t work?
- How do I get the author’s page url from their ID?
- How do I add a php statement to a jQuery string
- What’s the proper way to use wp_enqueue_script/style?
- Callback URL in WordPress
- Count number of published posts by type
- Wrong links in WordPress?
- Newbie question: no index.php? in my plain wordpress permalink
- How is WordPress manipulating the posts like there are folders?
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- Extract subdomain and relative address from a url
- Echo URL of large version of Featured Image
- Why does WordPress remove my variables in the URL?
- Adding subdomain to home_url for “add_menu_page”
- Dynamic content based on a URL parameter
- Colon is Missing In My Website Url in WordPress
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to use $_GET function WordPress backend
- Extend PHP regex to cover “srcset” and “style” attributes
- My php header() function is not working [closed]
- Scrape external webpage for first image and add it to new post
- Create custom permalinks to show Custom Post Type’s relationship?
- Replace shortcode in substring
- Search Query: how to construct a search string from two select elements?
- Get URL Parameters from referer
- Need help enqueueing webfonts
- Insert custom PHP head above in WP pages
- Why is $wp->request empty in WordPress 6.0?
- How to check if the current page is at a specified path in the URL?
- WordPress function and string as variable?
- How to pass a PHP $_GET variable and fetch/output it?
- Changing the color scheme based on the url visited
- Post’s ID pattern?
- How to return site_url() without https://
- How set a custom URL for a new theme file in WP?
- I’m unable to call img path using single quotes in an array?
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- Filter results from a serialized string to use on statistics
- change default RSS feed URL
- How do i add slugs to a URL, but still redirecting to the same page
- Can’t change website Title on wordpress
- PHP $_REQUEST array empty
- Nginx WordPress and another Web app URL structure
- How to use title attributes in sidebar widget?
- how to get attached file url for current post?
- Call featured image url
- Creating customized php files in theme folder
- How do I include an external PHP file in a subdir WordPress install?
- How to add PHP pagination to wordpress
- Use an anchor link to open an iframe inside a WordPress page
- Adding custom url to readmore link using get_permalink()
- How to set base url for php widget
- Comment_author_url doing nothing
- Modifying WP URL handing code?
- How to deal with a GET variable of ‘name’?
- WordPress permalink issue
- Custom functions for string data calculations
- WordPress is removing query variables like page, p from the URL of a custom static page
- Workaround for og:image unsupported webp image type, Yoast SEO?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Unable to display multiple parameters from url by javascript through shortcodes
- Allow two posts (from different categories) to have the same slug
- Prepend to all image URLs with PHP, only for mobile devices
- Get nice name of category from slug (remove dashes of category)
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Add Link to PHP message
- Current WordPress Page Title as Search Parameter into A Tag
- Rewrite rule not working, but only when parameter is text
- Get WordPress username to customize url
- WordPress/NGINX not respecting the category URL for new posts
- How does one make a URL return dynamic JSON with custom Content Type?
- Meta inserted through wp_insert_post gets messed up
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- problem in using wpdb->prepare and a string placeholder
- WordPress add_rewrite_rule
- Need to Echo A Url path to show on a wordpress page
- I want url from a file in media using title file
- How do I generate formatted permalinks as specified in backend options?
- Previewing/Updating some Pages causes “The requested URL was rejected” Error
- changing static link to relative link
- Create a dynamic buddupress tab
- extract url from a hyperlinked string in PHP [closed]
- How do you detect if a specific word is at the end of a the_title()
- site_url() returns with additional backslashes
- Retrieve first image url from custom post with pagination
- Magento and WordPress URL integration [closed]
- Passing multiple variables through url (php)
- check if .min.css stylesheet exists
- How to remove parent section in an attachment URL in wordpress?