CPT = Пользовательские типы сообщенийСписок таксономических почтовых отправлений
Я создал CPT, который отлично работает в моем Wordpress.
Вот код:
register_post_type('clases-tinka',
// CPT Options
array(
'labels' => array(
'name' => __('Academy'),
'singular_name' => __('Academy')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'tinka-academy'),
// Features this CPT supports in Post Editor
'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments'),
'has_archive' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'taxonomies' => array('academy-tax','category'),
)
);
Я зацикливание все эти CPT в PHP документ, который вы можете увидеть здесь http://tinka.com.co/es/tinka-academy/
Вот код:
$i = 1;
//added before to ensure it gets opened
echo '<div class="row-cursos">';
$wp_query = new WP_Query(array('post_type' => 'clases-tinka', 'posts_per_page' => 100, 'orderby' => 'title', 'order' => 'ASC'));
if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();
// post stuff...
?>
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="clasesclass">
<div><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div>
<div><a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a></div>
<div class="datosclase">
<?php
$horast = get_field('horas_del_curso');
$diast = get_field('dias_split');
$personast = get_field('cantidad_de_personas');
?>
<h4><?php if ($horast == "1") { echo "Curso de " .$horast. " Hora";} else { echo "Curso de " .$horast . " Horas";} ?></h4>
<h4><?php echo $diast ?></h4>
<h4><?php if ($personast == "1") { echo "Grupo de " . $personast ." Persona";} else { echo "Grupo de " .$personast ." Personas";} ?></h4>
<p>Category: <?php $terms = get_terms("academy-tax"); $count = count($terms); if ($count > 0){ foreach ($terms as $term) { echo $term->name; } } ?>
</p>
</div>
<div class="botonenlace">
<a href="<?php the_permalink(); ?>" target="_self" class="tcvpb-button tcvpb-button_red tcvpb-button_rounded tcvpb-button_small ripplelink ">Ver Más<i class="typicons-media-play"></i></a>
</div>
</div>
</div>
<?php
// if multiple of 3 close div and open a new div
if($i % 3 == 0) {echo '<div style="clear:both"></div></div><div class="row-cursos"><hr>';}
$i++; endwhile; endif;
//make sure open div is closed
echo '</div>';
?>
</div> <!-- Container End -->
<div class="container">
<?php
$terms = get_the_terms('clases-tinka', 'category');
// Want a list of category here
?>
</div>
Я не хорошо понимайте, как работают таксономии, я хочу список только категорий, которые я создал в этом CPT.
Я искал, не мог понять, как его любая помощь была бы большой! –