function apiGetSupplies() {
$supplies = array();
if ( $this->f3->exists( 'supplies' ) ) {
$supplies = $this->f3->get('supplies');
$counter = $this->f3->get('counter');
echo json_encode($supplies[$counter]);
$counter++;
$this->f3->set('counter',$counter);
} else {
//some sql call to define supplies
$this->f3->set('supplies',$supplies);
$this->f3->set('counter',0);
}
}
我想根据名称打印每个自定义帖子的名称和自定义ID。
<?php $loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1)); ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<?php
$i = 1;
$terms = get_the_terms($post->ID, 'tagportfolio');
foreach ($terms as $term) {
?>
<div class="col-md-3 col-sm-6 mix
<?php echo $term->name . ' ' . $i; ?> ">
<div class="pdf-thumb-box"> <a class="fancybox-media" href="<?php the_field('url'); ?>">
<div class="pdf-thumb-box-overlay">
<span>
<?php the_title(); ?>
</span>
</div>
<img class="img-responsive center-block" src="<?php the_post_thumbnail_url('medium'); ?>">
</a>
</div>
</div>
<?php
$i++;
}
?>
<?php
endwhile;
wp_reset_query();
?>
project
$i
$i
至$i
答案 0 :(得分:0)
请试试这个:
<?php
$terms = get_terms( array(
'taxonomy' => 'tagportfolio'
) );
foreach($terms as $term) {
$i = 1;
$loop = new WP_Query(array('post_type' => 'project', 'orderby' => 'menu_order', 'order' => 'ASC', 'posts_per_page' => -1,'tax_query' => array( array('taxonomy' => 'tagportfolio', 'field' => 'id', 'terms' => $term->term_id))));
while ($loop->have_posts()) : $loop->the_post(); ?>
<div class="col-md-3 col-sm-6 mix <?php echo $term->name . ' ' . $i; ?> ">
<div class="pdf-thumb-box">
<a class="fancybox-media" href="<?php the_field('url'); ?>">
<div class="pdf-thumb-box-overlay">
<span>
<?php the_title(); ?>
</span>
</div>
<img class="img-responsive center-block" src="<?php the_post_thumbnail_url('medium'); ?>">
</a>
</div>
</div>
<?php $i++; ?>
<?php
endwhile;
wp_reset_query();
}
?>