Learning to Display Posts by Taxonomy?

Here is the situation, I have a custom tax called Skill, i want to be able to display posts only with skill set as Japanese from English.

I am trying to learn how to use pre_get_posts hook to modify my get_posts query here is my example however i land with the error:

Notice: Undefined variable: postdata

This is what i have tried based on research:

add_filter( ‘pre_get_posts’, ‘wpshout_fundraiser_recent_posts’ );
function wpshout_fundraiser_recent_posts( $query ) {

    // Fetch only posts tagged with "Japanese from English"
    $taxquery = array(
            'taxonomy' => 'Japanese from English',
            'field' => 'skill',
            'terms' => array( 'skill' ),
    $query->set( 'tax_query', $taxquery );

I am sure something is wrong with the above query, which i dont fully understand. Any help and please explain what each field of the array is for if possible.

Thanks guys

Read more here: Learning to Display Posts by Taxonomy?

Leave a Reply

Your email address will not be published. Required fields are marked *