WordPress的 - 回声价值Query_Posts
问题描述:
我需要呼应WordPress的查询中的值。这里是我的查询第一:WordPress的 - 回声价值Query_Posts
<?php if(have_posts()):?>
<?php query_posts('cat=14&posts_per_page=3');?>
<h1><?php echo get_the_category_by_id(14); ?></h1>
<?php the_content();?>
<?php endwhile;?>
<?php wp_reset_query(); ?>
<?php endif;?>
我需要呼应的价值是这样的:<?php echo $tgh_first_category; ?>
我需要的地方它说:“14”,以呼应这一点 - 所以我需要更换cat=14
和id(14)
与那回声。
我该怎么做?
答
所以,如果我得到这个权利你与主PHP语法规则基本上是陌生?那么你应该仔细阅读有关php.net的文档以熟悉它。
至于你的问题,你的代码应该变成这样:
<?php if(have_posts()):?>
<?php query_posts('cat=' . $tgh_first_category . '&posts_per_page=3');?>
<h1><?php echo get_the_category_by_id($tgh_first_category); ?></h1>
<?php the_content();?>
<?php endwhile;?>
<?php wp_reset_query(); ?>
<?php endif;?>