Code to append all links in a page?

I use WordPress to do web design. I’m gradually learning to manipulate the php files. I’m looking to create a must-use plugin I can add that will first test what theme is loaded, then, if it’s a certain theme, append all links on the page with “?mobile”. The idea is use a particular link containing “?mobile” that will (via a theme switcher plugin) tell the website to load a certain theme. Then, the must-use plugin would change all links from there, on.

I know how to check for the theme, I’m already doing that in other parts of the site. I just don’t what code to write to alter all links present on the page, or if that’s even possible.

You can add rewrite rules to your .htaccess file and you won’t have to change any code anywhere.

Here’s a sample one - doesn’t apply to you, I don’t know you wordpress file structure.

[php]RewriteRule /pages/(.*) /page.php?mobile [R][/php]

You can read more about how to use URL Rewrites here.

http://httpd.apache.org/docs/2.4/rewrite/intro.html

I would agree with this easy approach.

Thank you.

Now to learn how to write htaccess code…

Sponsor our Newsletter | Privacy Policy | Terms of Service