WordPress custom query by archive title

I have just made this on a rush but would you please try this :

<?php 
 if( is_tag() ){
   $tag = single_tag_title('', false);
 }else{
   $tag='';
 }
if( is_category() ){
 $cat = single_cat_title('', false);
}else{
  $cat="";
}

$args = array(
  'post_type'      => 'post',
  'post_status'    => 'publish',
  'tag'            => $tag,
  'posts_per_page' => $ppp,
  'category_name'  => $cat,
  'offset'         => $offset,
);
?>