show correct category name and fix post title permalink wordpress
<p>I use this code to show different posts in different divs.</p>

<p>I have 2 problems:</p>

<ol>
<li><p>I can't show the correct category name to current post.</p>

<ul>
<li><p>The same category name is applied to 2 post when I use:</p>

<pre><code>get_category_link($recent['ID'])
</code></pre></li>
</ul></li>
<li><p>Clicking on the post title redirect me to home page instead post's page!</p>

<pre><code>    &lt;div class="modulex"&gt;
        &lt;?php
        $args = array('numberposts' =&gt; '1', 'post_status' =&gt; 'publish', 'offset' =&gt; '2');
        $recent_posts = wp_get_recent_posts($args);

        foreach ($recent_posts as $recent) {?&gt;

           &lt;div&gt;&lt;?php echo get_the_post_thumbnail($recent['ID'],'small', array('class'=&gt;'img-fluid')); ?&gt;&lt;/div&gt;
            &lt;div class="spanlike"&gt;&lt;h6&gt;&lt;a href="&lt;?php get_permalink($recent["ID"]) ?&gt;"&gt;&lt;?php echo $recent["post_title"] ?&gt;&lt;/a&gt;&lt;/h6&gt;&lt;/div&gt;

        &lt;?php } ?&gt;
    &lt;/div&gt;&lt;?php
    wp_reset_query();
    ?&gt; 
</code></pre></li>
</ol>