【问题标题】:Wordpress - Echo Value in Query_PostsWordpress - Query_Posts 中的回声值
【发布时间】:2012-02-02 16:03:10
【问题描述】:

我需要在 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 wp_reset_query(); ?>
<?php endif;?>

我需要回显的值是:&lt;?php echo $tgh_first_category; ?&gt;

我需要回显它来代替它显示“14”的位置 - 所以我需要用那个回显替换 cat=14id(14)

我该怎么做?

【问题讨论】:

    标签: php wordpress echo


    【解决方案1】:

    那么,如果我说对了,您基本上是不熟悉主要的 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;?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-07
      • 2011-03-15
      • 2013-04-23
      • 1970-01-01
      • 2014-10-13
      • 1970-01-01
      • 2016-10-05
      • 1970-01-01
      相关资源
      最近更新 更多