skip to Main Content

Now it’s showing like this: now it’s showing like this

I want it to look like this: I want it to look like this

2

Answers


  1. There are two ways to do:

    1. In your WordPress dashboard, go to Appearance » Widgets and add the ‘Recent Posts’ widget to your sidebar.
      https://prnt.sc/1rhjdc4

    2. Using wp query

    $args = array(
        'post_type'      => 'product',
        'posts_per_page' => 10,
    );
    $loop = new WP_Query($args);
    while ( $loop->have_posts() ) {
        $loop->the_post();
        ?>
        <div class="entry-content">
            <?php the_title(); ?>
            <?php the_content(); ?>
        </div>
        <?php
    }
    
    Login or Signup to reply.
  2. wp_get_recent_posts( array $args = array(), string $output = ARRAY_A )
    Please read this article
    https://developer.wordpress.org/reference/functions/wp_get_recent_posts/

      <?php
      $recent_posts = wp_get_recent_posts();
      foreach( $recent_posts as $recent ) {
          printf( '<li><a href="%1$s">%2$s</a></li>',
              esc_url( get_permalink( $recent['ID'] ) ),
              apply_filters( 'the_title', $recent['post_title'], $recent['ID'] )
          );
      }
      

      ?>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search