0

I want to create a post feed that displays the following:

  • ALL posts in the CPT 'custom_post_type_1'
  • Any 'post's in the category 'speakers'

So far, I have this filter which displays all posts in 'custom_post_type_1' and all posts in 'post".

add_action( 'elementor/query/my_custom_filter', function( $query ) {
    $query->set( 'post_type', ['post', 'custom_post_type_1'] );
} );

I suspect I need to do a taxonomy array to accomplish my goal but am having difficulty writing one which filters only 'post' and which also shows all of 'custom_post_type_1' regardless of taxonomy.

I am fairly new to this and appreciate any assistance. (I am using Elementor, hence the mention of elementor in the query.)

2
  • The key question is: does your CPT have the speakers taxonomy as well? In that case, you can't use only pre_get_posts. You could leave the filter as is, and then in your template, filter the posts further inside the loop. if (get_post_type() === 'post' && !has_term('', 'speakers')) continue
    – Paul
    Jul 21 at 10:35
  • No, the CPT does not currently have the 'speakers' taxonomy as well. (I could set it up if it made sense). Currently I am having difficulties filtering the posts inside of the loop—I think that's an Elementor limitation.
    – srack
    Jul 25 at 18:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.