Php wordpress-返回相同结果的类别的多个get_选项
我有两段代码,都试图分别从不同类别中提取一篇文章,但它们都返回同一篇文章——确切地说是第二篇文章的内容。这是我的密码Php wordpress-返回相同结果的类别的多个get_选项,php,wordpress,wordpress-theming,posts,Php,Wordpress,Wordpress Theming,Posts,我有两段代码,都试图分别从不同类别中提取一篇文章,但它们都返回同一篇文章——确切地说是第二篇文章的内容。这是我的密码 <!-- homepage block 1 - START --> <? $homepage = get_option('of_homepage') ?> <?php query_posts('category_name='.$homepage.'&posts_per_page=1'); ?> <?php
<!-- homepage block 1 - START -->
<? $homepage = get_option('of_homepage') ?>
<?php query_posts('category_name='.$homepage.'&posts_per_page=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Add your content here -->
<div id="m2" class="f-ms">
<div id="m3" class="f-ms">
<h3 class="subtitlessmaller f-fp f-lp">
<?php the_title(); ?>
</h3>
</div>
<div id="m4" class="f-ms">
<p class="whitewider f-fp">
<?php the_content(); ?>
</p>
</div>
</div>
<?php endwhile;?>
<!-- homepage block 1 - END -->
<!-- homepage block 2 - START -->
<? $homepage2 = get_option('of_homepage2') ?>
<?php query_posts('category_name='.$homepage2.'&posts_per_page=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Add your content here -->
<div id="featboxtitle" class="f-ms">
<p class="f-fp f-lp"><span class="subindex"><?php the_title(); ?></span></p>
</div>
<div id="featimage" class="f-ms">
<p class="f-fp f-lp"><?php the_post_thumbnail(''); ?></p>
</div>
<p class="smaller">
<?php the_content(); ?>
</p>
<?php endwhile;?>
<!-- homepage block 2 - END -->
我对Wordpress完全陌生,所以如果我想做的不可能,请原谅我。我找到了自己的解决方案。我需要在theme-options.php文件中为每个帖子添加一个类别,然后从管理面板的主题选项中选择它们,就像这样
//Select Category
$options[] = array( "name" => "Select a Category for the first homepage greeting",
"desc" => "Hit the dropdown and select a category from the listings",
"id" => $shortname."_homepage",
"std" => "Select a category:",
"type" => "select",
"options" => $of_categories);
//Select Category
$options[] = array( "name" => "Select a Category for the second homepage block of text",
"desc" => "Hit the dropdown and select a category from the listings",
"id" => $shortname."_homepage2",
"std" => "Select a category:",
"type" => "select",
"options" => $of_categories);
我要祝贺自己今天能如此好地帮助自己:-)