Custom page for each term

Asked

Viewed 30 times

1

I have a taxonomy called Staff and a term called Professores, i created the page taxonomy-staff.php to display all teachers contained in taxonomy staff and taxonomy-staff-professor.php to display registered teachers with the term teacher, but it is not displaying the page, it even obeys the route and changes the title of the page, but the content does not appear. Can someone help me?

follows the link from taxonomy-stafftax-professor.php

https://jsfiddle.net/uxyaumj4/

<?php
  get_header();
  get_template_part( 'wp-files/partials/banner' );
?>

<div class="content">
  <h3>Perfis dos professores</h3>
  <?php
    $args = array(
      'posts_per_page' => -1,
      'post_type' => 'staff',
      'post_status' => 'publish',
      'tax_query' => array(
        array(
          'taxonomy' => 'stafftax',
          'field' => 'slug',
          'terms' => 'professor',
          )
        )
    );

    $loop = new WP_Query( $args );
    if ( $loop->have_posts() ) :  while ( $loop->have_posts() ) : $loop->the_post();

    $terms = get_the_terms( $post->ID, 'stafftax');
  ?>

  <ul>
    <li>
      <a href="<?php echo get_permalink(); ?>">
        <?php echo get_the_title(); ?>
      </a>
    </li>
  </ul>

<?php
  endwhile;
  endif;
  wp_reset_query();
?>


<?php get_footer() ?>
  • 1

    Include your code, the error is probably in it ;)

1 answer

0


You are rewriting the query, so you may be having problems.

Try it this way: Filing cabinet taxonomy-stafftax-professor.php

<?php
  get_header();
  get_template_part( 'wp-files/partials/banner' );
?>

<div class="content">
  <h3>Perfis dos professores</h3>
  <ul>
  <?php if ( have_posts() ) :  while ( have_posts() ) : the_post(); ?>
    <li>
      <a href="<?php echo get_permalink(); ?>">
        <?php echo get_the_title(); ?>
      </a>
    </li>
<?php
  endwhile;
  endif;
  wp_reset_query();
?>
  </ul>    

<?php get_footer() ?>
  • I managed, actually, I just needed to create the single-{taxonomy}. php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.