Yes, you can add the query string to the permalink by using the add_query_arg()
function. The add_query_arg()
accepts three arguments i.e. $key
, $value
and the $url
.
# output - https://example.com/hello-world?foo=bar
echo add_query_arg(
'foo',
'bar',
'https://example.com/hello-world'
);
Check the add_query_arg() documentation for more details - https://developer.wordpress.org/reference/functions/add_query_arg/