I recently had this code created for my Wordpress site. It makes it so that unregistered users can not see the newest posts available up to 15 days unless they register. It works, but I need it to only restrict one specific category in my Wordpress installation and not all of them (i.e. I need it to restrict this category but not my blog posts).
Can anyone tell me where and what is needed to make this code function this way? Thanks.
add_filter('posts_where', '_custom_s2member_archive_filter');
function _custom_s2member_archive_filter($where) /* Require membership to view latest content. */
{
if(!is_admin() && (is_archive() || is_home()) && !current_user_can("access_s2member_level1"))
{
$where .= " AND post_date <= '".date ("Y-m-d", strtotime ("-15 days"))."'"; /* Back-date freeloaders. */
}
return $where;
}
add_filter('template_redirect', '_custom_s2member_single_filter');
function _custom_s2member_single_filter() /* Require membership to view latest content. */
{
global $post; /* Need this for date comparison. */
if(!is_admin() && is_single() && !current_user_can("access_s2member_level1"))
{
if(strtotime($post->post_date) > strtotime("-15 days"))
{
header("Location: ".S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL);
exit();
}
}
}