WordPress powered site that's setup having a custom top of the page. Typically, the leading page is structured like so:
Cat 1 Title Latest publish from category
Cat 2 Title Latest publish from category
Cat 3 Title Latest publish from category
The issue is, a publish could be designated to several category. So, I possibly could write a publish "Sample Publish" and publish it within the Cat 1 and Cat 2 groups. Came from here, the leading page would display that publish under a couple of the groups, also it would be also the newest publish, so it might be released as Sample Publish for groups around the home page.
I'm looking to get the publish to simply be shown under one category around the home page. Every other recommendations in regards to this problem would be also welcomed.
I am unsure what method you're using to retrieve the outcomes, but you should use the
exclude parameter to exclude certain posts from queries (i.e. the posts which have already made an appearance).
To begin with setup an exclusion array:
$exclude_this = array();
Within the loop, add the post's ID to that particular array. For instance within the loop:
$exclude_this = get_the_ID();
After which on each query use that array to exclude any posts which are inside. For instance, to obtain all posts from category with ID 5, except the posts in
$query = new WP_Query( array( 'category__in' => array(5) , 'post__not_in' => $exclude_this, ) );
I have not examined the above mentioned, however it should work.You may must make sure
$exclude_this is a range of integers, instead of their string representation.