I searched everywhere on the web and I didn't find something that could really help me. Here is my problem;

I use a plugin that provides shortcodes to show a file in a page or a post. For each file I need to write 2-3 shortcodes to change the 'url' part of that shortcode, and depends on the subdomain I am, I want to hide the shortcodes that aren't concerned. I tried some solutions;

First, put each shortcode into a div with a specific class then hide it. Failed

Second, try to add directly a class in the shortcode, try to find it and replace it by an empty string. Failed

Third, try to find the shortcode by the name and modify its url (so an unique shortcode per file). Failed

I don't know which code could work, I took it from some websites (this one and this one for example) and tried to 'mix' them, but it hasn't worked like I would..

Does someone have a solution ?

  • you need to check the post id, if match the exclusion, then don't show the shortcode.
    – Ari
    Commented Sep 16, 2015 at 14:17
  • @SoursopTree I don't think I need to check the post_id.. And how do I hide the shortcode ?
    – Sovnfield
    Commented Sep 17, 2015 at 5:35
  • What do you want to hide the shortcode based on?
    – Ari
    Commented Sep 17, 2015 at 6:48
  • @SoursopTree On the subdomain (like product1.domain.com)
    – Sovnfield
    Commented Sep 17, 2015 at 6:53

1 Answer 1


Check it like this inside your php file:

if($_SERVER["HTTP_HOST"] == "product1.domain.com") { // check the current domain
// your shortcode here. use do_shortcode to display the shorcode

I can help better if you post the codes that handle the shortcode.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.