Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Display specific posts on pages in WordPress Re: Display specific posts on pages in WordPress

#104052
ramiro
Member

Thank you the code that Michael post is great.


$post_slug = 'online-coupons';
$args=array(
'name' => $post_slug,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'List of Posts';
while ($my_query->have_posts()) : $my_query->the_post(); ?>

" rel="bookmark" title="Permanent Link to ">


endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>

But I still have the problem that I want to display 2 or more posts per page so I need something like

'name' =>array($post_slug),

But it looks like you can’t do an array on the name argument.