Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Last active January 23, 2024 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrasguseo/a22cbb1917c98a9fbf5a47c012b37d76 to your computer and use it in GitHub Desktop.
Save andrasguseo/a22cbb1917c98a9fbf5a47c012b37d76 to your computer and use it in GitHub Desktop.
Filter Bar > Open the Filter Bar on mobile on initial pageload
<?php
/**
* Open the Filter Bar on mobile on initial pageload.
*
* By default, Filter Bar is closed on mobile regardless of the setting.
* With this snippet Filter Bar will show on pageload when using the horizontal setup.
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar, Filter Bar
* Created: January 19, 2024
*/
function tec_open_filterbar() {
echo '<script>
let fbSelector = document.querySelector(".tribe-filter-bar.tribe-filter-bar--horizontal");
if(fbSelector != null) {
fbSelector.classList += " tribe-filter-bar--open";
fbSelector.style.position = "unset";
}
</script>';
}
add_action( 'wp_footer', 'tec_open_filterbar' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment