Query Anything On WordPress Anywhere

<?php
$args = array(
      'posts_per_page'   => '3',
      'post_status'   => 'publish',
    );
$recent_posts = wp_get_recent_posts( $args );
// Loop each post
foreach( $recent_posts as $recent ) {
  echo get_the_title($recent["ID"]);
  echo $recent["post_content"];
}
wp_reset_query();
?>

Refer the WP_Query class reference for a complete list of arguments.

Another Approach

<?php 
$my_query = new WP_Query( array(
  'posts_per_page'  => 3,
  'post_status'  => 'publish',
  'paged'  => get_query_var('paged', 1),
));
  
while ( $my_query->have_posts() ) : $my_query->the_post();
  
  post_class();
  the_title();
  the_permalink();
  the_excerpt();
  
endwhile;
wp_reset_query();
?>
Hello, I am Arun Basil Lal. Thank you for reading!

I am a WordPress product developer and creator of Image Attributes Pro. I am passionate about solving problems and travelling the world.

Divi WordPress Theme - My Review

Divi WordPress Theme
Divi is a WordPress theme that web designers do not want you to know. It comes with a drag-and-drop theme builder. You can build beautiful looking unique websites without touching a line of code. Just choose from one of the many pre-made layouts, or pick elements and arrange them any way you like.

Divi is every WordPress developer's wet dream. Surprise your clients with neat responsive websites and have fun building them.

Divi comes from Elegant Themes. If you enjoy building websites, you *need* an Elegant Themes membership. 87 beautiful themes and 5 plugins for the cost of less than a candy-bar each!


Note: I am an avid user of Divi myself and this is a honest review. I wouldn't recommend something that I do not personally find amazing.

no responses.

4 Pings / Trackbacks.

  1. […] For an example, see this: Query Anything On WordPress Anywhere […]

  2. […] Refer: Query Anything On WordPress Anywhere […]

  3. […] Also refer: Query Anything On WordPress Anywhere […]

  4. […] Query Anything On WordPress Anywhere […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*