2013-06-27 46 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