- This topic has 11 replies, 3 voices, and was last updated 2 years, 3 months ago by Ying.
-
AuthorPosts
-
January 3, 2022 at 6:27 pm #2068245Den
Hello Team,
I previously raised a request where I wanted to remove the Sidebars on mobile devices ( But with PHP (not by CSS) ) because I wanted to speed up my mobile version.
Leo and Ying gave me 2 different suggestions. This one (Link To The Sugession) worked for me.
But, after a while, I figure out that this isn’t working fine. On some pages, it worked like a charm. But on few other pages, it just starts completely removing the sidebar from the Desktop screens as well.
I don’t want it to re-shape my website on the desktop version as google itself suggest that one should not make big visual changes as it will negatively impact SEO for the computer version.
I also followed Ying’s version METHOD LINK but it didn’t worked.
—————————
I have given a video link in the Private Information section. In the provided video, you can clearly see what i am trying to say.
+
As of now, I have removed the PHP code. You’ll probably going to see the normal version on both devices.January 3, 2022 at 7:22 pm #2068268ElvinStaffCustomer SupportHi Den,
But, after a while, I figure out that this isn’t working fine. On some pages, it worked like a charm. But on few other pages, it just starts completely removing the sidebar from the Desktop screens as well.
Can you copy clone site w/ the suggested fix to a staging site and let us check the pages where the issue occurs?
Also, can you tell us how you’ve checked these pages? Note: If you’ve checked this through a desktop browser inspecting on a mobile sized view, the code won’t work because the code will only work on actual mobile devices, not browser emulated viewport sizes.
January 4, 2022 at 11:29 am #2069161DenHi Elvin,
I have pasted that PHP code on my live website’s function.php (again) and cleared the Cache. You will most likely to see it now.
I checked all the pages in incognito mode + kproxy as well. But found that there must be the PHP that is causing the issue. I checked on both devices. ON MOBILE DEVICES, IT WORKED PERFECTLY but on the desktop screen, I saw that the PHP code is removing the sidebars on wider screens as well.
Note: (removing the sidebars on wider screens) But not from all posts, that is where it gets a little confusing. I checked random pages and on some pages, it wasn’t causing any issue but some of the pages get affected by the PHP code.
————-
New Screen Record Video Link Is In Private Information Section.
January 4, 2022 at 11:44 am #2069177YingStaffCustomer SupportCan you link us to the page where we can see the issue?
January 4, 2022 at 11:46 am #2069179DenI have pasted a link in the Private Information Section.
January 4, 2022 at 12:07 pm #2069206YingStaffCustomer SupportThat’s very weird.
Any chance you can create a staging site, and provide admin access so we can take a look at the backend?
January 4, 2022 at 12:15 pm #2069211DenActually, it will be very hectic for me to create a new one and move everything there as I am planning to shift my house. Ying, you gave a 2nd method [HERE] and i tried it but it didn’t work.
Is there any other method or trick that I can follow? Have you discussed this with David? He sometimes gives the best solution possible. Maybe he’ll tweak something in this.. cuz I don’t have any knwlg related to PHP. [Here] is the David’s method
January 4, 2022 at 12:23 pm #2069217YingStaffCustomer SupportThe PHP snippet David provided should work for all posts, I just want to check if there’s anything special on that specific post.
it will be very hectic for me to create a new one and move everything there as I am planning to shift my house
Creating a staging site only requires some clicks, you can try a plugin called WP STAGING.
And the method I provided should work too, I tested it before I posted it.
January 4, 2022 at 12:29 pm #2069224DenYing, Any chance you can provide me a video tutorial where i can follow your method step by step.
January 4, 2022 at 12:39 pm #2069230YingStaffCustomer Support1. Create a layout element at appearance > elements: https://www.screencast.com/t/bTgQ4Mx5
2. Set posts > all posts as location in Display rule:
https://www.screencast.com/t/wQX2f6oKSF3. Get the element ID from the element editor URL:
https://www.screencast.com/t/SxGOn1grz4. Add this PHP snippet, change the ID to match yours:
add_filter( 'generate_element_display', function( $display, $element_id ) { if ( !wp_is_mobile() && 2134 === $element_id) { $display = false; } return $display; }, 10, 2 );
But this method is basically the same thing as David’s snippet.
When you are testing this method, remember to deactivate David’s snippet.
January 4, 2022 at 12:52 pm #2069238DenI will try this. Hopefully, this works 🤞
If not… still you guys are doing a great job.
Thank you
January 4, 2022 at 12:59 pm #2069247YingStaffCustomer SupportI would suggest check if there’s any specific settings for that post 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.