I am new at Wordpress. I have two pages namely 'Newsletters' and 'Service News' to show the news in my website. I want to show the posts belonging to a particular category in these pages. The page 'Newsletters' should pull all the posts belonging to category slug 'newsletters' and the page 'Service News' should pull all the posts belonging to category slug 'service-news'. How can i do so?
Somewhere i found that the following code can perform so.
<?php $catPost = get_posts(array('category' => get_cat_ID(“newsletters”)));
$event=array_splice($catPost, 0, 1);
foreach ($event as $post) : setup_postdata($post);
the_content(); ?>
But on writing the code on the text editor of the page, the whole code gets shown in the page. Am i doing it wrong? Can't we write php codes in the editor. Have spent my much time in looking for this but could not solve this problem.
Please help me.
Thank you in advance