Question
How can I modify this code to not show posts from new categories that we just added.
I searched other similar answers on this site [such as: Exclude category on blog list page ] but not sure how to convert that into usable code in my project.
Background
We have different pages that will show links to recent posts. On the main blog page we need to hide links to posts from 5 different categories.
Code - page
<ul>
<?php
if (isset($_GET['tag'])):
$tagparam = filter_var($_GET['tag'], FILTER_SANITIZE_STRING);
endif;
$postslist = get_regular_posts_query('25','',$tagparam);
while ( $postslist->have_posts() ) {
$postslist->the_post();
?>
Code - functions.php
// Get Non-Featured Posts using WP_QUERY
function get_regular_posts_query($numberposts,$categoryName=NULL,$tagName=NULL){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => $numberposts,
'post_status' => 'publish',
'category_name' => $categoryName,
'post_type' => 'post',
'orderby' => 'post_date',
'tag' => $tagName,
'meta_query'=>array(
'relation'=>"OR",
array(
'key' => "featured_post",
//'value' => "featured",
'compare' => "NOT EXISTS"
),
array(
'key' => "featured_post",
'value' => "",
'compare' => "="
)
),
'paged' => $paged,
);
$posts = new WP_Query( $args );
if(! $posts ) {
//throw new Exception("NoSuchPost");
echo "No Articles Found!";
}
return $posts;
}
From other research that I did, i found that you have to put in the IDs of the categories. Mine are: 89, 90, 91, 92, 93.