I want to detect if the subdomain is “m.”, and if so display a different template. Couldn’t find what I was looking for, in the WordPress API to do so.
Leave a Reply
You must be logged in to post a comment.
I want to detect if the subdomain is “m.”, and if so display a different template. Couldn’t find what I was looking for, in the WordPress API to do so.
You must be logged in to post a comment.
You can use the parse_url() function in PHP to do this:
Then, you can add your own if statement:
You should use the ‘template_redirect’ filters, or one of the other _template filters to change the template thats being loaded.
I suggest to create you own plugin with one single script and put it in wp-content/plugins with a code like this:
Then go in the admin , look for you new plugin and enable it