2011-12-19 21 views
-2

我有一個函數如下,list_child_sibling_pages,當最初的2 if/ifelse語句爲false時,它返回一個'hidden'字符串。獲取不帶回聲的變量的字面值

我需要在「隱藏」的字面返回值放到下面圖中顯示的陣列

陣列(「類名」 =>「定製親子菜單容器」。$隱藏,「說明'=>'自動添加一個子頁面菜單到父頁面,自動添加一個兄弟菜單到子頁面');

我知道我可以與將其輸出與

回波list_child_sibling_pages();

但我不知道如何在下面的代碼中工作。該值返回的罰款,如果我只是附和它在它自己的我唯一的問題是呼應它,我需要它

相關代碼如下

功能tmm_child_parent_menu(){

function list_child_sibling_pages() 
{ 
global $post;// if outside the loop 
$post_type = '&post_type='.get_post_type();  
$children = get_pages('child_of='.$post->ID.$post_type); 
$parent_title = get_the_title($post->post_parent); 
$parent_permalink = get_permalink($post->post_parent); 
  
//child pages 
    if ($post->post_parent && !is_search() && !is_404())  
    { ?>  
      <h4><?php echo '<a href="'.$parent_permalink.'">'.$parent_title.'</a>'; ?></h4> 
      <ul class="parent-page-children"> 
      <?php wp_list_pages('title_li=&child_of='.$post->post_parent.'&sort_column=menu_order'.$post_type); ?> 
      </ul> 
     <?php  
    }  

//parent pages 
    elseif (count($children) != 0 && !is_search() && !is_404()) 
    { ?> 
      <h4><?php the_title(); ?></h4> 
      <ul class="parent-page-children"> 
      <?php wp_list_pages('title_li=&child_of='.$post->ID.'&sort_column=menu_order'.$post_type); ?> 
      </ul> 
     <?php  
    }  
    else  
    { 
     return 'hidden'; 
    } 
} 

    $hidden = list_child_sibling_pages(); 
    /* Widget settings. */ 
    $widget_ops = array('classname' => 'custom child-parent-menu-container '. $hidden, 'description' => 'Automatically add a child page menu to parent pages. Automatically add a sibling menu to child pages'); 

回答

0

困惑,但我想你想

 $array=array('classname'=>'custom child-parent-menu-container '.list_child_sibling_pages(), 
'description'=>'Automatically add a child page menu to parent pages. Automatically add a sibling menu to child pages'); 
+0

不幸的是其實我已經試過了 $ widget_ops =陣列(「類名」 =>「定製親子菜單共ntainer'.list_child_sibling_pages(),'description'=>'自動添加一個子頁面菜單到父頁面。自動添加兄弟菜單到子頁面'); 但這似乎沒有爲我返回任何東西。在html中的類列表中沒有添加任何內容。 – phantomdentist 2011-12-20 12:40:52