- This topic is empty.
-
AuthorPosts
-
September 30, 2013 at 10:00 am #151710amisParticipant
hey everybody
I am working in wordpress theme and i make custom post type called ‘videos’ and make taxonomy for it call types
types will be like comedy , drama .. etc
now i want to get custom posts under comedy only in one page and also for other types
i have been created this page taxonomy-type.php and used this loop
<?php if(have_posts()) : ?> <?php while(have_posts()) : the_post(); ?> // post here <?php endwhile; ?> <?php else : ?> // not found <?php endif; ?>
but not work with me ! i hope anyone help me
October 1, 2013 at 1:37 am #151775EnergParticipantYou need to use a custom WP_query. Something like this:
$args = array(
‘post_type’ => ‘post’,
‘tax_query’ => array(
‘relation’ => ‘AND’,
array(
‘taxonomy’ => ‘movie_genre’,
‘field’ => ‘slug’,
‘terms’ => array( ‘action’, ‘comedy’ )
),
array(
‘taxonomy’ => ‘actor’,
‘field’ => ‘id’,
‘terms’ => array( 103, 115, 206 ),
‘operator’ => ‘NOT IN’
)
)
);
$query = new WP_Query( $args );You can read more here.
October 1, 2013 at 3:22 am #151782amisParticipantthx Energ
i have been used this but not work with me
<?php $args = array( 'post_type' => 'videos', 'tax_query' => array( 'relation' => 'AND', ), array( 'taxonomy' => 'type', 'field' => 'slug', 'terms' => array( $term->slug ) ) ); $query = new WP_Query( $args ); ?> <?php if(have_posts()) : ?> <?php while(have_posts()) : the_post(); ?>
i will show you what i want defiently
i want when go to this link get what in it
http://localhost/wp/?type=comedy (get comedy only )
http://localhost/wp/?type=action (get action only)
October 2, 2013 at 7:02 am #151901SenffParticipantTo list all posts of type “videos” that have “comedy” checked in the custom taxonomy “type“:
$args = array( 'post_type' => 'videos', 'type' => 'comedy' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); echo '- '.get_the_title().'<br>'; // other loopy stuff here endwhile;
More info: http://www.senff.com/front-end/on-custom-taxonomies/
October 2, 2013 at 1:40 pm #151919amisParticipantthx Senff but not work with me
the name of my page is taxonomy-videos.php
and i want loop in it will be suitable for thishttp://localhost/wp/?type=comedy
http://localhost/wp/?type=action
http://localhost/wp/?type=drama -
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.