display post format text in loop

get_post_format() returns the post format slug for either the current post, when used inside a loop, or a given post, when a WP_Post object or an integer post ID is passed to it as a parameter.

So, if you’re using the function in a posts loop, then you can use it like this,

while ( have_posts() ) {

  the_post();

  if ( 'gallery' === get_post_format() ) {
    echo 'Gallery';
  } else {
    echo 'Not Gallery';
  }

}