I think I managed to solve this.
What I did was to add the following in my functions.php
file:
add_filter( 'posts_where', 'exclude_my_posts' );
function exclude_my_posts( $where ) {
global $wpdb;
// For the front page. Hide posts with "efter15" set to "Ja", and only show posts with "show_on_front_page" set to "Nej"
if (is_front_page()) {
return $where . " AND $wpdb->posts.ID NOT IN ( SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = 'efter15' AND meta_value="Ja" ) AND $wpdb->posts.ID NOT IN ( SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = 'show_on_front_page' AND meta_value="Nej" )";
}
// Always show all in dashboard
elseif (is_admin()) {
return $where;
}
// Everywhere else: Hide posts with "efter15" set to "Ja"
else {
return $where . " AND $wpdb->posts.ID NOT IN ( SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = 'efter15' AND meta_value="Ja" )";
}
}
And in my index.php file – which is also used for category, tag etc (therefore the is_front_page()) for now at least:
<?php if (is_front_page()) {
query_posts(array('category_name' => 'notiser', 'paged' => get_query_var('paged')));
} ?>
Then follows the loop and the rest. Looks good so far.