Try to echo 2 relationships fields…
-
Hello, can you help me?
I have three taxonomies in my blog (days, activities, hotels). These three taxonomies behave as follows:
– One day can have several activities in different hotels
– An activity can be held at a hotel on different days
– A hotel can arrange different activities on different daysWhat I want is to print a listing as follows:
Day # 1
activity
hotel
schedule
—-
activity
hotel
schedule
—
…Day # 2
activity
hotel
schedule
—
…I have this code to register de connections:
p2p_register_connection_type( array( 'name' => 'hoteles_to_actividades', //hotels_to_activities 'from' => 'hotel', //hotel 'to' => 'actividad' //activity ) ); p2p_register_connection_type( array( 'name' => 'dias_to_actividades', //days_to_activities 'from' => 'dia', //day 'to' => 'actividad', //activity 'fields' => array( 'horario' => array( //schedule 'title' => 'Horario', //Schedule 'type' => 'text', ), ) ) );
And this other code to try to print the listing…
query_posts('post_type=dia&posts_per_page=-1&order=DESC'); //day if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); $connected = new WP_Query( array( 'connected_type' => 'dias_to_actividades', //days_to_activities 'connected_items' => get_queried_object(), 'nopaging' => true, 'connected_orderby' => 'title', 'connected_order' => 'desc' ) ); if ( $connected->have_posts() ) : while ( $connected->have_posts() ) : $connected->the_post(); echo $post->post_title . '<br />'; endwhile; wp_reset_postdata(); endif; endwhile; endif; wp_reset_query();
My result with this code is almost nothing…
Day #1
Day #2
Day #3
…Can anybody help me?
Thanks in advance !!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Try to echo 2 relationships fields…’ is closed to new replies.