0

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?

1 Answer 1

1

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() ) { ... }

Sign up to request clarification or add additional context in comments.

4 Comments

can I user media query?
you can, if you use media query, you will hide headers for mobile browsers, ios devices etc too
You wouldn't be changing a function for media queries, you should find the style.css file of your template, and add @media (max-width: 768px) { #header{display:none;}.. } and so on.
Media query will hide your header and footer on mobile web, too.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.