2013-08-16 10 views
5

Próbuję wyświetlić niestandardowy typ wpisu, który ma niestandardową taksonomię, ale nie mam szczęścia. Nic nie pokazuje się. Doceniam każdą pomoc.Niestandardowa taksonomia WP_Query

typu post = galeria

klienta Taksonomia ślimak = photoarea

do 'photoarea' Chcę, aby wyświetlić = czwarty

enter image description here

<?php 

$args = array( 
       'post_type' => 'gallery', 
       'tax_query' => array(
        array(
         'taxonomy' => 'photoarea', 
         'field' => 'fourth', 
         ) 
       ), 
       'posts_per_page' => 10, 
      ); 

$the_query = new WP_Query($args); 


if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); 

    the_post_thumbnail(); 

endwhile; endif; 

wp_reset_query(); 

?> 

Odpowiedz

1

jeśli moje zrozumienie jest prawo, że musisz uzyskać niestandardową taksonomię z następującym kodem: zamiast field ty muszą używać term uzyskać posty na czwartym

<?php 

$args = array( 
       'post_type' => 'gallery', 
       'tax_query' => array(
        array(
         'taxonomy' => 'photoarea', 
         'term' => 'fourth', 
         ) 
       ), 
       'posts_per_page' => 10, 
      ); 

$the_query = new WP_Query($args); 


if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); 

    the_post_thumbnail(); 

endwhile; endif; 

wp_reset_query(); 

?> 
+0

Nie działa dla mnie. Wywołuje powiadomienie PHP. –

+0

potrzebujesz "pola" => "ślimak" i "warunki" => "czwarte", aby uzyskać tę pracę, a nie "termin". –

1

Możesz skorzystać z poniższego fragmentu kodu:

$the_query = new WP_Query('post_type=gallery&photoarea=fourth'); 

a następnie pętla czasu.

-2
$args = array('post_type' => 'gallery','posts_per_page'=>'-1','tax_query' => array(array(
             'taxonomy' => 'photoarea', 
             'field' => 'term_id', 
             'terms' => $your_term_id, 
            ), 
           ), 
          ); 
Powiązane problemy