T
T
TopClans2017-08-31 11:59:35
Mobile devices
TopClans, 2017-08-31 11:59:35

Wordpress: is it possible to make a full-fledged separate template for mobile?

Good afternoon!
I am familiar with WordPress, I have modified templates for it a couple of times, but I cannot call myself an expert.
There was such a need: to make a main and mobile version of the site, but at the same time, the mobile version, although it should be in a similar style to the main one, should still have a completely different structure.
I tried various plugins for creating mobile versions - they offer, as a maximum, to remove some widgets there.
I need the menu to be in a different place, of a different kind.
So, the question is: is there any way to explain to WP that when entering from a mobile, you need to open the mobile template, and when entering from a PC, the pc template?
So far, I have not found such a "chip", I just came up with a bunch of checks in the main template using wp_is_mobile () and, it turns out, in fact, paint both the PC version and the mobile version in one template, but this is wildness.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2017-08-31
@deniscopro

Good afternoon.
Any Mobile Theme Switcher . In the settings, you can specify for which devices which theme to show.
If within the same theme, then you can use the template_include hook and, by checking for mobile, include different templates.

add_filter( 'template_include', 'mobile_template', 99 );

function mobile_template( $template ) {

  if ( wp_is_mobile()   ) {
    $new_template = locate_template( array( 'mobile-template.php' ) );
    if ( '' != $new_template ) {
      return $new_template;
    }
  }

  return $template;
}

Usually such questions are solved with the help of css rules and, possibly, js. Hide one menu, show another.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question