I have a website which is built using WordPress, now I want to make an android app which will use this website. I want the header/footer to be dynamic as follows:
User access | header displayed?
app | no
android browser | yes
Any idea or suggestions how to do it? Is there any WordPress, android or JavaScript plugin which I can use?
Set a User-Agent on your web view in your Android app and then check the User-Agent in your WordPress templates to decide what to show/hide.
For instance, include sitename-native-app
in your User-Agent. This explains how to set your User-Agent in Android: android user agent
On the WordPress side, create a function to check the User Agent. Example:
function is_native_app() {
return ( false !== strpos( strtolower( $_SERVER['HTTP_USER_AGENT'] ), 'sitename-native-app' ) );
}
Then, in your template where you include your header and footer, wrap with:
if ( ! is_native_app() ) { ... }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.