1

I would like for my WordPress post link to refer people to different pages depending on the OS that they are using. For example to download Mac version of software if they are browsing from MacOS.

I saw a tutorial on how to add user OS in function.php file, but i have no idea how to implement function on a specific WP page.

1 Answers1

1

Based on that tutorial you don't need to change page link. On same page you can do that. Like section/button for Mac/windows.

Here how you can do:

Step1: Add the code on your functions.php then you will see on your website under body tag have a specific class if you are form Mac then "osx" or if you are from windows then "windows"

Step2: add class on you Mac section called "osxsection" & for windows section "windowssection"

Step3: Now do the css like this:

// to view the section on Mac
.osx .osxsection {
display: block !important;
}
.osxsection {
display: none;
}

// to view the section on Windows
.windows .windowssection {
display: block !important;
}
.windowssection {
display: none;
}

you can present that CSS code some different way also.

Try that hope it will help you :)

mrhossen
  • 122
  • 8
  • Sorry i'm lost on step 1 already. By "under body tag" you mean the header.php page? if so there is no OS specific class in there. And as you mentioned I do want to have it on the same page. What I would like if this was a perfect world, for a user to go on my site.com/downloadskype and see some text and a link to Skype for Mac if they are on Mac. And if they would go on the same page from their Windows PC to see exact same text but link would refer them to the Skype for Win download page. – Kat Demidova Apr 06 '18 at 16:43
  • You understand wrong. read Step1 carefully. I said add the code in functions.php on your theme. then reload the website then you will see it detect specific class based on OS. you will see the class on body tag. Hope you got it now. – mrhossen Apr 06 '18 at 17:34