Hello,
I don’t understand what you want, but i Think is homepage and not -homepage
No ?
I want to exclude the posts tagged with homepage.
I also tried $query = new WP_Query( 'cat=-11' );
but it isn’t working either.
Are you try category__not_in in your query ?
Also not working:
$query = new WP_Query( 'category__not_in => 11' );
Ok
Ihave found this
<?php
$temp_query = $wp_query;
$exclude = get_cat_ID('showreel');
query_posts("cat=-$exclude&post_type=projects&showposts=4&order=ASC");?>
Try width this exemple. Do an variable $exclude and add -$exclude to your query…
I hope it will work !
<?php
$args = array(
'category_name' => 'homepage',
);
$query = new WP_Query( 'cat=-$args' );
?>
isn’t working either 🙁
I don’t know if is a googd solution but you can do a pre get post if you dont want to show posts by the category…
In your functions.php
function demo_exclude_category( $wp_query ) {
// Add the category to an array of excluded categories. In this case, though,
// it's really just one.
$excluded = array( '-1' );
// Note that this is a cleaner way to write: $wp_query->set('category__not_in', $excluded);
set_query_var( 'category__not_in', $excluded );
}
add_action( 'pre_get_posts', 'demo_exclude_category' );
Change the good ID of your category…
Maybe, but I only want it on one page… 🙂
Hello
I have try it and it’s work !
<?php
query_posts(array(
'post_type' => 'post',
'showposts' => 5,
'cat' => '-1'
) );
?>
<?php if ( $query->have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
get_template_part( 'content', 'news' );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
Still not working: suddenly I get pages in the newsfeed :p
You also need to change while ( have_posts() ) : the_post(); to while ( $query->have_posts() ) : $query->the_post();
Yes! 🙂
Thank you for your help!
You’re welcome ! I haven’t seen the $query->have_posts(). I’m tired !
Happy it’s work have a good day !