Ask your WordPress questions! Pay money and get answers fast! (more info)

Same question, new thread.


I previously wrote a question here, but it expired. So:

Original question:

Kyle, this is what I've got right now. Not working though, getting all posts at the moment:

if ( ( is_front_page() && $query->is_main_query() ) || is_feed() ) {

$args = array(

'fields' => 'id',

'post_type' => 'usp_post',

'tax_query' => array(


'taxonomy' => 'firstpage',

'field' => 'slug',

'terms' => array('featured')




$remove_these = get_posts( $args );

$query->set( 'post_type', array( 'post', 'usp_post' ) );

$query->set( 'posts_not_in', $remove_these );


Answers (1)


Kyle answers:

So you are trying to remove the 'featured' posts, correct?

Kyle comments:

If you remove the surrounding conditionals:

if ( ( is_front_page() && $query->is_main_query() ) || is_feed() ) {


Does it work then?

Jens Filipsson comments:

Yes. Would of course prefer if I could just check the ones I wanted to add to the first page, but I understand that this could be hard because of the two different post types..


Jens Filipsson comments:

No, unfortunately it won't work without conditionals either.

To be clear:

The taxonomy is called firstpage and the term (tax "category") is featured.

Kyle comments:

I made a typo in my code, change posts_not_in to post__not_in

Jens Filipsson comments:

Still not working unfortunately. Tried enabling debug mode, and it throws this error:

Notice: Object of class WP_Post could not be converted to int in .../wp-includes/functions.php on line 3334

Kyle comments:

Which line of this is 3334 in your functions file?

Jens Filipsson comments:

It's in the wordpress core functions file:

function absint( $maybeint ) {
return abs( intval( $maybeint ) );