Content Visibility for Wordpress is not working (Drafts, public etc.)
I have an old WordPress installation. Unfortunately, public posts and drafts are displayed on the front. I think it's because of the wordpress loop. The following code is used:
section class="container container-fluid"
div id="layout" style="padding: 0 -15px;"
?php
if (has_tag('Karriere'))
ini_set("display_errors", 1);
$args = array('offset' = 0,
'numberposts' = 12,
'limit' = 12,
'post_type' = "post",
'orderby' = 'post_date',
'order' = 'DESC',
'category' = '26,60',
'tag' = 'Karriere');
//$args = array('numberposts' = 2);
$recent_posts = wp_get_recent_posts($args, ARRAY_A);
$_SESSION['home_offset'] = count($recent_posts);
foreach( $recent_posts as $recent ){
$post_uri = get_permalink($recent['ID']);
//$post_image = wp_get_attachment_url( get_post_thumbnail_id($recent['ID']) );
$post_image = wp_get_attachment_image_src( get_post_thumbnail_id($recent['ID']), 'vorschaubild');
$post_image = $post_image[0];
$post_categoryList = array();
$post_categories = get_the_category($recent['ID']);
foreach($post_categories as $post_category){
$post_categoryList[] = $post_category-slug;
}
$content = explode("!--more--", $recent['post_content']);
$content = $content[0];
$content = preg_replace('/a href=\"(.*?)\"(.*?)\/a/', "\\2", $content);
$content = preg_replace('/div id=\"(.*?)\" class=\"(.*?)\"(.*?)\/div/', "", $content);
?
div
div class="wrapper-karriere-box" style="padding: 0 5px;"
? //item echo htmlspecialchars($content); ?
a href="?=$post_uri?" title="?=$recent["post_title"]?"
div class="newsBox" data-categories="?=implode(",", $post_categoryList)?"
?php
if($post_image !== false $post_image !== NULL){
?
img src="?=$post_image?" style="width: 100%;" /
?php } ?
div class="news-box-headline"
h3?=$recent["post_title"]?/h3
p?=$content?/p
/div
/div
/a
/div
/div
?php } ?
/div
what i have to change that public posts and drafts are not shown in frontend (for unregistered users).
I hope somebody can help! Thanks a lot!