Display/Filter post using if else statement


Here it is: I want to filter my post based on category (Party) If the post with category Party has tag which is ‘event’, it is the one that will display If there is no ”event’ tag, only the recent post of Party category will display

here’s my code:

<?php      $  post_cat = array(             'posts_per_page' => '1',             'cat' => '3'             );     $  post_tag = array(             'posts_per_page' => '1',             'cat' => '3',             'tag' => 'event'             );       $  catquery = new WP_Query( $  post_cat );     $  tagquery = new WP_Query( $  post_tag );          if(has_tag()) :          while($  tagquery->have_posts()) : $  tagquery->the_post();            else if(has_category()) :        while($  catquery->have_posts()) : $  catquery->the_post();          else ?> <?php $  backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($  post->ID), 'full' );?> <div class="blog-post-recent" style="background-image: url('<?php echo $  backgroundImg[0]; ?>');">     <div class="wrap">         <div class="blog-post-content">             <div class="blog-post-inner-content">                 <?php the_category();?>                 <div class="blog-post-title"><a href="<?php the_permalink() ?>"><?php the_title( '<h2>', '</h2>' ); ?></a></div>                 <div class="post-date"><?php the_date('F j, Y'); ?></div>                 <?php the_excerpt(); ?>                 <a class="blog-post-btn"  href="<?php the_permalink() ?>"> Read More...</a>';             </div>         </div>     </div> </div> <?php endif;     wp_reset_postdata(); ?>