I have to code for showing recent post on my home page custom theme it works good

function.php 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">';
if ( has_post_thumbnail() ) {
echo '<a class="single-image link-icon" href="'.get_permalink().'">';
$list .=the_post_thumbnail(array(300,200),array('alt' =>$title));   
 echo '</a>';
echo '<h6 class="title"><a href="'.get_permalink().'"><span>'.$title.'</span></a></h6>';
echo '<div class="entry-body">';
$list .= wpe_excerpt('wpe_excerptlength_index', '');
echo '<a class="button default color" href="'.get_permalink().'">Read More</a>';
echo '</div>';
echo '</div>';
return $list;
add_shortcode('recent-posts', 'my_recent_posts_shortcode');


this is a shortcode i have mentioned on my pages->Home page

for displaying the shortcode i have to use

                $post_id = 1746;
                $queried_post = get_post($post_id);
                <?php  $check=$queried_post->post_content; ?>
                <?php  echo do_shortcode($check);?>

For displaying shortcode i used $post_id of my home page i want i have to display shorcode content without using post_id.
When i mentioned shorcode on my homepage it automatically call that shorcode and display the result and my theme url is http://templategraphy.com/wp-demo/businessguru/
suggest some solutions.

Read more here: Shortcode Display From WordPress Dashboard Page Without Using post_id


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: