Site logo

Archived topic

hiding sections using hide-on-desktop class not working

3 replies · Started by Avinash on July 7, 2020

Viewing posts 1–4 of 4

Hi

I am trying to use sections, to show/hide content on the home page based on whether it is a mobile user or desktop.

Now, the class hide-on-desktop works well on sections as long as the content in the section does not include a shortcode. However, since the content I am trying to display is dynamic and retreived via custom shortcode, the class hide-on-desktop is not working.

This is the URL.

https://www.theinsidervoice.in/home-mobile/

The content must show only on mobiles not on desktops.

How can i address this issue

Pls help

Hi there,

Its to do with how the Shortcode is returning its content - Is it a plugin or a custom function that is generating the Shortcode ?

It is a custom plugin, that retrieves data from the backend and displays in table format

If you look at your sites markup you will see that the Tables are displayed outside of the Section.
This happens when the shortcode 'echoes' its output. It needs to return a single value or use output buffering to display within the container.

https://codex.wordpress.org/Shortcode_API

This archived topic is closed to new replies.