0

Regards, i've a problem.

What i want: Show a toggle with loop from Custom Post Type

I create post type: Episodio

And a Taxonomy: Temporada

I create this loop:

   <?php
        $post_type = 'episodio'; // <-- Post Type
        $tax = 'temporada'; // <-- Taxonomía
        $termino = get_terms($tax);
        if ($termino) {
            foreach ($termino as $temporada) {
            $args=array(
              'post_type' => $post_type,
              "$tax" => $temporada->slug,
              'post_status' => 'publish',
              'posts_per_page' => -1,
              'caller_get_posts'=> 1,
              'cat' => 'serie',
              'meta_key'=> 'numeroepisodio',
              'order_by'=> 'meta_value',
              'order' => 'ASC'
            );
        $query_episodios = null;
        $query_episodios = new WP_Query($args);
        if( $query_episodios->have_posts() ) {
          echo '<h3 class="titulo-temp" id="titulo-temp-'.$temporada->slug.'" onclick="tog(\''.$temporada->slug.'\')" ><i class="fa fa-chevron-right"></i>'.$temporada->name.'</h3><hr> <ul id="items-temp-'.$temporada->slug.'" class="items-temp">';
          while ($query_episodios->have_posts()) : $query_episodios->the_post(); 
          $numeroepisodio = get_post_meta($post->ID, 'numeroepisodio',true); ?>
           <a href="<?php the_permalink() ?>"><li><strong><?php  echo 'Episodio '.$numeroepisodio; ?>:</strong> <?php the_title(); ?> <img src="//cdn.enlatino.net/img/play.png" class="img-play"></li></a>
        <?php endwhile; } wp_reset_query(); } }?>

The result its correct, and work! but, this loop its same for all posts.

The loop come in a page template, if i create another page with this page template, the result its same.

I want to use one page template to all posts.

I don't know if i do this correctly, but the result what i want is something like this:

Serie 1: http://i.imgur.com/c3sZaV3.png

Serie 2: http://i.imgur.com/rjpc6LY.png

Problem and my loop in action: http://i.imgur.com/rp0yH5E.png

Same template to 2 series, only change the loop. But i don't know how to do this.

Sorry for my english, i'm from Argentina.

Thanks.

  • In your $args array you shoule change "$tax" to 'tax_query' and add a proper tax_query - codex.wordpress.org/Class_Reference/… – David Gard Feb 9 '15 at 12:23
  • @DavidGard that is valid usage and should work. However, to make this work, you will need to set query_var to true when registering your taxonomy. – Pieter Goosen Feb 9 '15 at 12:46
  • caller_get_posts is depreciated many years ago. Please turn debug on as you should have gotten a depreciation message if you had debug turned on. You should use ignore_sticky_posts. Also, what is cat and what is serie. The cat parameter only except a category ID, and only works with the build in taxonomy category – Pieter Goosen Feb 9 '15 at 12:50
  • i've really problem with the organization of the post type and taxonomies. tax_query doesn't work. i've quit caller_get_posts thanks. i forget to delete these line (cat=...) – Ferrrmolina Feb 9 '15 at 13:11
  • 1
    That is expected yes, and also correct. I really don't know how your structures look like, but you should rather create a shortcode for that and change your terms accordingly – Pieter Goosen Feb 9 '15 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.