The code below is for a query string named “theyear”. It adds the class “customHide” if the query string contains “2019”. If not, it adds the class “customHideTwo”.
For example, if your site URL contains this query string:
https://www.yoursite.com?theyear=2019
Add the following PHP code to your child theme functions.php file.
[php] // look for parameter in URL for year and add the class customHide if (isset($_GET['theyear'])) { $theyear = $_GET['theyear']; if ($theyear = '2019') { // Add specific CSS class by filter. add_filter( 'body_class', function( $classes ) { return array_merge( $classes, array( 'customHide' ) ); } ); } } else { //Handle the case where there is no parameter // Add the class customHideTwo add_filter( 'body_class', function( $classes ) { return array_merge( $classes, array( 'customHideTwo' ) ); } ); } [/php]
0 Comments