https://exemple.com/news-and-events/news/?id=assessing/litecoins/bounce-social-supremacy-and-everything-in-between/
I want pretty urls, like this: https://exemple.com/news-and-events/news/assessing/litecoins/bounce-social-supremacy-and-everything-in-between/
I added the following in functions.php:
function my_rewrite() {
add_rewrite_tag(
'%id%',
'([^/]+)'
);
add_rewrite_rule(
'^news/([^/]+)/?',
'index.php?pagename=news&id=$matches[1]',
'top'
);
}
add_action( 'init', 'my_rewrite' );
in page.php:
$id = get_query_var( 'id' );
// Grab data from the endpoint using $id
The redirect works, but if the slug after /news/ in my url contains a slash, get_query_var( ‘id’ ) returns only the characters within the first and second slash.
I assume the issue is in my regexp but I can’t seem to make it work. Any ideas would be greatly appreciated.
]]>I found on many sites dedicated to regular expressions that the syntax needed to convert all lowercase letters to uppercase ones on the replacement string was (for the first capturing group) :
\U$1
Looks like this doesn’t work. I have tried a few variants unsuccessfully …
What is the right syntax ?
Thank you
$tag = '(.+?)';
And maybe it’s better to take into account the start ^ and end $ of the string to all other rules
]]>If I enable RegExp option and use RegExp in Source URL, can I also use RegExp in Target URL? I try to use \. to express ., like below:
https://www.datanumen.com/downloads/files/dolkr\.exe
But will get a warning said “Your target URL contains the invalid character \”
]]>eg redirect from
/SWagm
to
/contractors-agm?utm_source=SW-AGM-2020&utm_medium=Flyer
now only ends up at
/contractors-agm/
if I search ‘oug’ it matches pages with ‘through’ on them.
Would be great if we could have a setting to ‘match whole words only’
there’s an implementation here as an idea although some of the code is deprecated
https://tinygod.pt/make-wordpress-search-exact/
essentially replacing eg
$list[] = 'd.post_title LIKE \'%' . $word . '%\'';
with
$list[] = 'd.post_title REGEXP \'[[:<:]]'.$word.'[[:>:]]\''
;
etc
thanks
J
^(.*)$
for redirecting all frontend URLs to another URL,/admin
and /wp/wp-admin/
as well, locking one out of the backend. I had to disable the plugin using WP CLI
via shell to regain access.