Php Wordpress-查询文章中的回显值
我需要在WordPress查询中回显一个值。这是我的第一个问题:Php Wordpress-查询文章中的回显值,php,wordpress,echo,Php,Wordpress,Echo,我需要在WordPress查询中回显一个值。这是我的第一个问题: <?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 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;?>
我需要回显的值是:
我需要在它说“14”的地方回显这个,所以我需要用这个回显替换cat=14
和id(14)
我该怎么做呢?如果我做对了,你基本上不熟悉主要的PHP语法规则?然后,您应该认真阅读上的文档以熟悉它 至于你的问题,你的代码应该是这样的:
<?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;?>