ceescoenen

Show on frontpage

Aug 12th, 2022 (edited)
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2.  
  3. // show element header-home__container when it is the homepage
  4. add_filter( 'bricks/element/render', function( $render, $element ) {
  5. // Get the element CSS classes
  6. $classes = ! empty( $element->attributes['_root']['class'] ) ? $element->attributes['_root']['class'] : false;
  7.  
  8. // Check if the element has the special class "hide-for-subscribers"
  9. if ( $classes && in_array( 'header-home__container', $classes ) ) {
  10. return is_front_page();
  11. }
  12.  
  13. return $render;
  14. }, 10, 2 );
  15.  
  16. // show element header-page__container when it is not the homepage
  17. add_filter( 'bricks/element/render', function( $render, $element ) {
  18. // Get the element CSS classes
  19. $classes = ! empty( $element->attributes['_root']['class'] ) ? $element->attributes['_root']['class'] : false;
  20. $front_page = ! is_front_page();
  21.  
  22. // Check if the element has the special class "hide-for-subscribers"
  23. if ( $classes && in_array( 'header-page__container', $classes ) ) {
  24. return $front_page;
  25. }
  26.  
  27. return $render;
  28. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment