【问题标题】:Wordpress: Echo PHP depending on page IDWordpress:根据页面 ID 回显 PHP
【发布时间】:2013-08-19 11:03:52
【问题描述】:

下午好,我正在尝试在模板中使用 PHP 显示帖子,但我使用相同的模板根据年龄 ID 输出不同的帖子。

我目前有这个有效的代码...

<?php //GET MEMBERS ?>
                    <?php query_posts('category_name=members&orderby=date'); ?>
                    <div class="row-fluid">
                        <ul class="thumbnails">
                            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                            <li class="span4">
                                <div class="thumbnail">
                                    <?php // check if the post has a Post Thumbnail assigned to it.
                                    the_post_thumbnail();
                                    ?>
                                    <div class="pad">
                                        <h3><?php the_title(); ?></h3>
                                        <?php the_content(); ?>
                                    </div>
                                </div>
                            </li>
                            <?php endwhile; ?>
                        </ul>
                    </div>
                    <?php endif; ?>

但我需要根据页面 ID 输出不同的“类别”... E.G

如果页面 id 是 7 echo "php script" 否则页面 id 为 13 echo "不同的 php 脚本"

谢谢,布拉德

【问题讨论】:

    标签: php wordpress posts


    【解决方案1】:

    Wordpress 有一些内置功能。您可以使用get_the_ID() 返回要在 if 语句中使用的 ID 号。

    问候

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多