Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For example, i am building a cinema site..

For movies - I am using post - The movies are post there.. For actors - I am using post_type : persoane , Taxonomy : lista.

How can i retrive the movies play by bruce willis in http://cinema.trancelevel.com/persoane/bruce-willis/

For example, i have : http://cinema.trancelevel.com/the-cold-light-of-day-2012-2/ This movie have Bruce Willis Tag....( this is a regolar post in wp)

In Bruce Willis page i want to retrive the movie.... that have Bruce Willis Tag

In conclusion i want to display the movies that actor play in

I anny body know please help. Thanks in advance

I try this but no sucess

<?php $args = array(
  'tax_query' => array(
    array(
      'taxonomy' => 'post',
      'field' => 'slug',
      'terms' => get_query_var('term')

    )
  )
);
query_posts( $args );
if ( have_posts() ) : while ( have_posts() ) : the_post();

  echo get_post_format();
endwhile; else:
  echo 'No movie found';
endif;
wp_reset_query();      
?>
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I think there are multiple issues here:

1) Because you're using query_posts() the post object's query_vars are inherited by your new query_posts(). I suspect then, that 'post_type' => 'persoane' is implicitly part of that query posts call. If you switch to using WP_Query instead of query posts, I suspect that will fix the issue.

2) Have you double checked that get_query_var('term') is returning what you expect? I think that only works on taxonomy archive pages. Instead, you'll want do use get_the_tags().

share|improve this answer
    
can you give me the exacte code please, will be apreciated... Thanks –  Batman Jul 7 '12 at 20:04
    
If I have time later, I'll try to work something up, but I couldn't even give you exact code without knowing more about what you want (e.g. how do you handle a post with multiple tags?). Read codex.wordpress.org/Function_Reference/get_the_tags and codex.wordpress.org/Class_Reference/WP_Query. They both have multiple code snippets that should take you quite far. If you can't get it working, post a follow up question and ping me here in the comments. –  mrwweb Jul 7 '12 at 20:36
    
i do not know php so much, can you please paste the code... i'm tring to get the movie cinema.trancelevel.com/the-cold-light-of-day-2012-2 , to link to the actor cinema.trancelevel.com/persoane/bruce-willis by tag.... so wen i add a movie in POSTS, i add a tag name Bruce Willis, after i go to PERSOANE ( new post_Type) i add the person... and under i need the code for displaying the movies play by actor by tag. i can give you acces with team wiew if you want... –  Batman Jul 8 '12 at 21:13
    
more: cinema.trancelevel.com/1.jpg , im using custom field, in post i get actors by Relationship for each movie... ok ... but how can i display automatic post (movies) that actor play in.... Note: i use for : =>>Movies : POSTS for Actors ==> post_type PERSOANE , Taxonomy lista... –  Batman Jul 8 '12 at 21:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.