title: How to Run this Code on front page only, not on subpages of Wordpress Index?
body: <p>I want to show last 5 modified posts from a specific category called "Featured" on the front page just below the regular posts, but not on the subsequent subpages. I am using this code to show these last five posts. Everything seems to be working fine except these 5 posts also run on the subpages.</p>
  
  <pre><code>function modified_postsbycategory() {
    // the query
    $the_query = new WP_Query( array( 'category_name' =&gt; 'featured', 'orderby' =&gt; 'modified', 'posts_per_page' =&gt; 5 ) ); 
  
    // The Loop
    if ( $the_query-&gt;have_posts() ) : ?&gt;
    &lt;?php
    while ( $the_query-&gt;have_posts() ) :
      $the_query-&gt;the_post();
  
              get_template_part( 'template-parts/content', 'modified' );
  
          // End the loop.
          endwhile;
  
      // If no content, include the "No posts found" template.
      else :
          get_template_part( 'template-parts/content', 'none' );
  
      endif;
      ?&gt;
    &lt;?php wp_reset_postdata(); ?&gt;
    &lt;?php
  }
    // Add a shortcode
    add_shortcode('categoryposts', 'modified_postsbycategory');
  </code></pre>
  
  <p>I am using this conditional tag just after the function starts, but I think I am not doing the right way. </p>
  
  <pre><code>&lt;?php if (is_front_page() &amp;&amp; !is_paged() ){ ?&gt;
  </code></pre>
  
  <p>Could you please help me?</p>
  
  <p>PS: Please check the code too and correct me if any errors found. I am just a learner, not expert.</p>