I am trying to display recent post in staic page home-content.php so i write a code in function.php

here it is a code

function my_recent_posts_shortcode($atts){
 $q = new WP_Query(
   array( 'orderby' => 'date', 'posts_per_page' => '4')
 );
$list ="";
while($q->have_posts()) : $q->the_post();
 echo '<div class="item">';
$title=get_the_title();
if ( has_post_thumbnail() ) {
 $list .= '<a class="single-image link-icon" href="'. get_permalink().'">'.the_post_thumbnail(array(300,200),array('alt' =>$title)).'</a>';
}
$list .= '<h6 class="title"><a href=the_permalink()><span>"'.the_title().'"</span></a></h6>';
echo '<div class="entry-body">';
$list .= wpe_excerpt('wpe_excerptlength_index', '').'<a class="button default color" href="the_permalink()">Read More</a>';
echo '</div>';
 echo '</div>';
endwhile;
wp_reset_query();
return $list ;
}
add_shortcode('recent-posts', 'my_recent_posts_shortcode');

[recent-posts] this is a shortcode for display recent post

and home-content.php for showing post

<?php 
$post_id = 7;
$queried_post = get_post($post_id);
?>
<p><?php  $check=$queried_post->post_content; ?></p>
<?php  echo do_shortcode('["'.$check.'"]');?>

all the recent post display on home page of my custom theme http://templategraphy.com/wp-demo/businessguru/

but the problem is no permalink is worked and the theme structure is not properly shown i

want this type of structure is shown http://templategraphy.com/demo/businessguru/

suggest some solution where i am doing wrong.

Read more here: Reecent post display using shortcode


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , ,

Wordpress related questions and answers: