phpface

Untitled

May 22nd, 2022 (edited)
980
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. add_action( 'pre_get_posts', function( $query ){
  2.     if( $query->is_archive() && $query->is_main_query() ){
  3.         $query->set( 'post_type', array( 'post', 'video' ) );
  4.     }
  5. }, 10, 1 );
  6. /**
  7.  *
  8.  * Filter the Archive widget
  9.  *
  10.  */
  11. add_filter( 'widget_archives_dropdown_args', function( $args, $instance ){
  12.     return array_merge( $args, array(
  13.         'post_type' =>  'video'
  14.     ) );
  15. }, 10, 2 );
  16.  
  17. /**
  18.  *
  19.  * Filter the Category widget
  20.  *
  21.  */
  22. add_filter( 'widget_categories_dropdown_args', function( $args, $instance ){
  23.     return array_merge( $args, array(
  24.         'taxonomy'      =>  'categories',
  25.         'value_field'   =>  'slug',
  26.         'class'         =>  'video-category-select'
  27.     ) );   
  28. }, 10, 2 );
  29.  
  30. add_action( 'wp_footer', function(){
  31.     ?>
  32.     <script type="text/javascript">
  33.         jQuery( '.video-category-select' ).on( 'change', function(e){
  34.             var slug = jQuery(this).val();
  35.  
  36.             window.location.href = '<?php echo trailingslashit( home_url( 'categories' ) ); ?>' + slug;
  37.         } );
  38.     </script>
  39.     <?php
  40. } );
  41.  
  42. add_filter( 'widget_text', function( $text ){
  43.     return do_shortcode( $text );
  44. }, 10, 2 );
Add Comment
Please, Sign In to add comment