Advertisement
fauzanjeg

JKIT || Redirect After Click Portfolio in Portfolio Gallery Widgets with Conditions

Mar 7th, 2024
957
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. /**
  2.  * Redirect After Click Portfolio in Portfolio Gallery Widgets
  3.  */
  4. function redirect_after_click_portfolio() {
  5.     $page_id = 8888; // Your Page ID
  6.  
  7.     if ( get_the_ID() === $page_id ) {
  8.         ?>
  9.         <script type="text/javascript">
  10.             (function ($) {
  11.                 $(document).on('ready', () => {
  12.                     const portfolio = $('.jkit-portfolio-gallery .row-item');
  13.  
  14.                     portfolio.on({
  15.                         click: (e) => {
  16.                             const url = $(e.target).closest('.row-item').find('.row-item-more a').attr('href');
  17.  
  18.                             window.location.href = url;
  19.                         }
  20.                     })
  21.                 })
  22.             })(jQuery)
  23.         </script>
  24.         <?php
  25.     }
  26. }
  27. add_action( 'wp_footer', 'redirect_after_click_portfolio' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement