Site icon Hip-Hop Website Design and Development

How one can create a shortcode with html and php code

This how i attempt it however does not work

perform blogPost(){
    return ?>
    <part class="blog container spacer">
      <article class="blog__list">
       <div class="glide-blog">
          <div class="glide__arrows" data-glide-el="controls">
            <button class="glide__arrow glide__arrow--left" data-glide-dir="<">&lt;</button>
            <button class="glide__arrow glide__arrow--right" data-glide-dir=">">&gt;</button>
         </div>
       <div class="glide__track" data-glide-el="track">
            <ul class="glide__slides">
    
           <?php 
            $the_query = new WP_Query( 'posts_per_page=3' ); ?>
              
            <?php 
            // Begin our WP Question
            whereas ($the_query -> have_posts()) : $the_query -> the_post(); 
            ?>
              
             <li class="glide__slide"><?php the_post_thumbnail('medium'); ?>
                <a href="<?php the_permalink() ?>" class="new-article__main-title"><?php the_title(); ?></a>
            </li>
              
            
              
            <?php 
            // Repeat the method and reset as soon as it hits the restrict
            endwhile;
            wp_reset_postdata();
            ?>
            </ul>
      </article>
    </part>
    <?php
}
add_action('blog-shortcode','blogPost');