How to add and delete individual menu depending on the screen resolution dynamically?

Good evening!
There is a full menu and a link to the page of the same site, separated from this menu, logo, are at the same level. If you reduce the size of the browser window this menu drops below the logo, and we need to ensure that the individual link was a part of the menu, and displays correctly, but when you increase the window size, respectively, separated from menu to the original position. This is somehow implemented?
June 10th 19 at 15:42
2 answers
June 10th 19 at 15:44
I do not quite understand what you mean, but it is possible that media queries (CSS3) will help You with this.
What do you specifically not understand, I thought I lucidly explained =) I don't need CSS, I need somehow to implement in php) - tillman18 commented on June 10th 19 at 15:47
And where PHP knows about the size of a screen of the user and PHP to know why this at all? - marilyne_Roh commented on June 10th 19 at 15:50
You're right , PHP does not know about the screen size.

Unless. something like this may help:
<?php
 if ( stristr($ua, "Mobile" )) {
$DEVICE_TYPE="MOBILE";
}

 if (isset($DEVICE_TYPE) and $DEVICE_TYPE=="MOBILE") {
 echo 'bla-bla';
}
?>
- rosario.Marv commented on June 10th 19 at 15:53
Not understand what you wrote, or do you want to say that this impossible task?) - tillman18 commented on June 10th 19 at 15:56
I nematatlin that it was the phone, for example, the window width is 1000px, but from this, and dance. The most interesting is the addition of paragraph) - tillman18 commented on June 10th 19 at 15:59
Interesting question) Read these topics... all of a sudden, you will find something useful.
Should look like the PHP code to query the resolution of the client browser?
www.cyberforum.ru/php-beginners/thread490684.html - rosario.Marv commented on June 10th 19 at 16:02
you see , I think that it is better to understand first how to add this menu code, and then deal with the width of the window - tillman18 commented on June 10th 19 at 16:05
,
you want to say that this impossible task?
I want to say that PHP so do not be - marilyne_Roh commented on June 10th 19 at 16:08
If we are to engage in such deportista, it is better to go from a GS on Beck viewport size and pixel density, and PHP they will bring to the session - marilyne_Roh commented on June 10th 19 at 16:11
Yes , in this case, it's better js. And with js you can load the link in the right side of the menu - rosario.Marv commented on June 10th 19 at 16:14
Yes
But it will not be used PHP
And so also it is not necessary to do - marilyne_Roh commented on June 10th 19 at 16:17
in fact it turns out the crutch) - rosario.Marv commented on June 10th 19 at 16:20
June 10th 19 at 15:46
Basically, WordPress has a useful function wp_is_mobile()which returns Boolean true/false. She shared desktops and mobile devices (tablets, smartphones). And it happens on the PHP side, i.e., on the server. However, in your case it is better to solve with CSS and media queries.
Igor, she might be useful, but I need it to implement on the desktop. That is to be manually adjusted to simulate the integrity of the menu? Or maybe better via JS to throw to that menu? - tillman18 commented on June 10th 19 at 15:49
so it is just you and allows you to do this:
if ( wp_is_mobile() ) { // true -> mobile device

} else { // false -> desktop

}

But, as I wrote in the answer, it is better to do via CSS. Print the desired menu item on the frontend always. Using the menu editor, assign the item an arbitrary CSS class so it's easy to target, and use a media query to show or hide when necessary. To do this on the server side - not quite right. - marilyne_Roh commented on June 10th 19 at 15:52
Igor and I have not all the permissions the desktop need to change the menu, so there's still need then check the width of the window, well that's another story. Well, let's say I asked a class to that menu item, but I don't have to hide, he is always in sight should be. Target is good, but I don't need to hide, but just to throw something in the menu then from the menu. - rosario.Marv commented on June 10th 19 at 15:55
make 2 menus, one with just this one paragraph, the second - the usual your menu (but also with this item). And turn-off your item in one of the menus when necessary, using CSS. - tillman18 commented on June 10th 19 at 15:58

Find more questions by tags WordPress