Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

96
Vistas
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(
        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 don't fully understand. Any help and please explain what each field of the array is for if possible.

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Try this below code this should work,

add_filter( 'pre_get_posts', 'wpshout_fundraiser_recent_posts' );
function wpshout_fundraiser_recent_posts( $query ) {

$posts_array = get_posts(
    array(
        'posts_per_page' => -1,
        'post_type' => 'Your Post Type Name',
        'tax_query' => array(
            array(
                'taxonomy' => 'Japanese from English',
                'field' => 'skill',
                'terms' => array( 'skill' ),
            )
        )
    )
);
return $posts_array;

}
about 4 years ago · Santiago Trujillo Denunciar

0

Here you can check:

$args = array(
'posts_per_page' => 5,
'post_type' => 'Post Type Name',
'tax_query' => array(
 array(
'taxonomy' => 'category_taxonomy',
'field' => 'slug',
'terms' => "Category Name"
)));
$query = query_posts( $args );
while (have_posts()) : the_post();
the_content();
endwhile;

view more

about 4 years ago · Santiago Trujillo Denunciar

0

$posts_array = get_posts(
    array(
        'posts_per_page' => -1,
        'post_type' => 'post_type_name',
        'tax_query' => array(
            array(
                'taxonomy' => 'taxonomy-name',
                'field' => 'term_id',
                'terms' => $cat->term_id,
            )
        )
    )
);
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda