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(
        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?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: