我需要通过自定义字段在我的单打页面中定义类别ID,以便根据页面加载不同的类别。这是我到目前为止所做的,它不起作用。
任何帮助都将不胜感激,谢谢。
<?php query_posts( \'cat=<?php echo get_post_meta($post->ID, \'BarID\', true); ?>id&showposts=1000\' ); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- BEER ITEM -->
<div class="menu-title">
<span><?php the_title(); ?></span>
</div>
<div class="menu-desc-wrap">
<div class="beer-discripton">
<span></span>
<?php the_content(); ?>
</div>
<div class="percent"><span> <?php echo get_post_meta($post->ID, \'Percent\', true); ?></span></div>
</div>
<!-- BEER ITEM END -->
<?php endwhile; ?>
<?php else : ?>
<p>Not Found</p>
<?php endif; ?>
我也试过:
<?php $cataID = get_post_meta($post->ID, \'cata\', false); ?>
<div class="one-half column">
<h3 class="title-color"><img class="img-valign-draft" src="<?php bloginfo(\'template_directory\'); ?>/images/draft-bottle/draft.svg" alt="">Draft</h3>
<?php query_posts( \'cat=\'$cata\'&showposts=1000\' ); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- BEER ITEM -->
<div class="menu-title">
<span><?php the_title(); ?></span>
</div>
<div class="menu-desc-wrap">
<div class="beer-discripton">
<span></span>
<?php the_content(); ?>
</div>
<div class="percent"><span> <?php echo get_post_meta($post->ID, \'Percent\', true); ?></span></div>
</div>
<!-- BEER ITEM END -->
<?php endwhile; ?>
<?php else : ?>
<p>Not Found</p>
<?php endif; ?>