2013-06-27 53 views
0

我有两块代码都试图从不同的类别分别拉出单个帖子,但他们都返回相同的帖子 - 第二个的内容是确切的。这里是我的代码...wordpress - 类别的多个get_option返回相同的结果

 <!-- 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

我发现我自己的解决方案。我需要ASIGN一个类别,在主题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); 
+0

我想自己上是这样的,祝贺对我自己今天是一个很好的帮助:-) – user2317093