[Support request] Sidebar PHP issue

Home Forums Support [Support request] Sidebar PHP issue

Home Forums Support Sidebar PHP issue

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #2068245
    Den

    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.

    #2068268
    Elvin
    Staff
    Customer Support

    Hi 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.

    A wise man once said:
    "Have you cleared your cache?"

    #2069161
    Den

    Hi 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.

    #2069177
    Ying
    Staff
    Customer Support

    Can you link us to the page where we can see the issue?

    #2069179
    Den

    I have pasted a link in the Private Information Section.

    #2069206
    Ying
    Staff
    Customer Support

    That’s very weird.

    Any chance you can create a staging site, and provide admin access so we can take a look at the backend?

    #2069211
    Den

    Actually, 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

    #2069217
    Ying
    Staff
    Customer Support

    The 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.

    #2069224
    Den

    Ying, Any chance you can provide me a video tutorial where i can follow your method step by step.

    #2069230
    Ying
    Staff
    Customer Support

    1. 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/wQX2f6oKSF

    3. Get the element ID from the element editor URL:
    https://www.screencast.com/t/SxGOn1grz

    4. 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.

    #2069238
    Den

    I will try this. Hopefully, this works 🤞

    If not… still you guys are doing a great job.

    Thank you

    #2069247
    Ying
    Staff
    Customer Support

    I would suggest check if there’s any specific settings for that post 🙂

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.