• To improve the navigation for mobile, I have defined different reusable blocks for desktop and mobile. On desktop, a list of posts is displayed directly, while the same list for mobile is located in an accordion. The reusable blocks are controlled via hide-on-desktop / hide-on-mobile but this loads the lists twice.
    I would therefore like to use a wp_is_mobile filter, but I don’t know how the reusable blocks are addressed.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Synced patterns are saved as posts of the “wp_block” type. In order to use wp_is_mobile() you need to use PHP, which means you’d need to register a custom block pattern in your theme’s /patterns/ folder. This PHP can get other content from the DB such as posts of type “wp_block”. So you’d use this pattern to conditionally get content from either the mobile or desktop synced patterns.

    If your theme is subject to periodic updates, do not add your pattern file to the theme. Instead create a child theme and add it there.

Viewing 1 replies (of 1 total)
  • The topic ‘How to use synced patterns (reusable blocks) with wp_is_mobile’ is closed to new replies.