2012-11-22 106 views
0

我想在我的主頁顯示滑塊第二條件......這種說法<?php include (TEMPLATEPATH . '/featured-narrow.php'); ?>使我得到一個滑塊..無法achiev在if語句

我發現下面的代碼在我home.php

<?php if (get_post_meta($postid, 'post_featcontent', true) == "Yes") { ?> 
       <?php include (TEMPLATEPATH . '/featured-vids.php'); ?> 
      <?php } ? 

我敢肯定,如果我改變這種狀況,我能顯示一個滑塊......

其實,「如果」語句,我需要2個條件:a)檢查主頁和b )它遇到了「post_featcontent」的值等於「N」的條件箭頭寬度特色內容滑塊」 ......

我試過如下:

if (is_front_page() && get_post_meta($postid, 'post_featcontent', true) == "Narrow Width Featured Content Slider") 

我能夠有成功的),但我無法實現對於b條件)(順便說一句,這是一個WordPress的。但是,這只是一個PHP的疑問,我覺得..)

任何人都可以幫助請.. ..?

編輯:

$meta_boxes = array(

     "layout" => array(
      "name" => "layout", 
      "type" => "select", 
      "title" => __("Page Layout", "solostream"), 
      "description" => __("Select a layout for this page/post.", "solostream"), 


     "post_featcontent" => array(
      "name" => "post_featcontent", 
      "type" => "select", 
      "title" => __("Add Featured Articles/Posts to This Post", "solostream"), 
      "description" => __("If you'd like to add featured articles/posts to the top of this post, make your selection below.", "solostream"), 
      "options" => array(
        "No", 
        "Full Width Featured Content Slider", 
        "Narrow Width Featured Content Slider")), 

); 
+3

你爲get_post_meta(...)得到了什麼print_r()? – toxicate20

+1

使用PHPmyAdmin或任何您使用的方式檢查數據庫,請檢查wp_postmeta表,瞭解post_featcontent的值是...或print_r它。很有可能這個定製元的價值不是你想象的那樣。 –

+0

@ toxicate20&@ShawnWernig +1。我建議當OP在[stackoverflow.com/questions/13498265/retreive-value-from-array-of-array](Http://stackoverflow.com/questions/13498265/)中提出同樣的確切問題時,做類似的事情從數組中取得數值),現在'關閉' – Sean

回答

-1

改變你的if語句包含另一個組括號

if ((is_front_page()) && (get_post_meta($postid, 'post_featcontent', true) == "Narrow Width Featured Content Slider") 
    ){ 

基本上要分開每個條件,以滿足特定條件的,

即:if((this = this)& &(this = this))

其中兩個條件都需要爲true才能繼續, 要做到這一點,用圓括號包裝每個條件,然後用另一組圓括號封裝兩者。

+0

我上面編輯過,可以再看看..? – Otero