0
votes

I have a wordpress page with this custom post types:

  • Movies
  • Blurays

Movies has a custom taxonomy (genres) with movieĀ“s genres and Blurays has a custom metabox "Belongs to movie" with movie Id.

In the blurays custom post type archive page I want to show all the genres and count blurays by them.

This is working now in http://sinentradas.com/comprar-peliculas-80/

But this is because both custom post types have genre custom taxonomy and I want one of this posibilities:

  • Only movies has it and using metabox "Belongs to movie" show all the bluray filtered by movies genres.
  • Share custom taxonomy without repeat it in both custom post types.

I tried creating a custom taxonomy "genrebr" but if a genrebr doesnt exists it generates a 404.

Is possible that I try?

1

1 Answers

0
votes

If I understood you right, you want:

  • get all movies that belong to a bluray
  • get the custom_taxonomy from the movie

you can fetch the movies (and get their post_id) and then use wp_get_post_terms() to fetch the custom_taxonomy

wp_get_post_terms($movie_post_id, 'custom_taxonomy', array("fields" => "ids"));

https://codex.wordpress.org/Function_Reference/wp_get_post_terms