我有2个代码块,它们分别试图从不同的类别中提取一个帖子,但它们都返回相同的帖子 - 确切地说是第二个的内容。这是我的代码......
<!-- 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的新手,所以请原谅我,如果我想做的事情是不可能的
答案 0 :(得分:0)
我找到了自己的解决方案。我需要为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);