2012-01-24 58 views
0

問題要問你。WordPress的行動幫助有關WordPress的post.php中?行動=編輯

我想如果get_post_meta一定的值,顯示在post.php中?行動=編輯頂部的通知...任何意見,我怎樣才能更有效地做到這一點?我似乎沒有得到這個代碼的迴應。

add_action('admin_notices', 'HMMultipostMU_notifyChild'); 

if(!function_exists('HMMultipostMU_notifyChild')){ 
function HMMultipostMU_notifyChild(){ 
    global $hmMultipostMU; 
    if(!isset($hmMultipostMU)){ 
     return;  
    } 

    if($meta = get_post_meta($post_id, 'HMMultipostMU_parent', true)) { 
     $parent = unserialize($meta); 
     if(!empty($parent)) { 
      foreach ($parent as $key => $value) { 
       switch_to_blog($key); 
       echo '<div id="message" class="updated highlight"> WARNING: This is a child article! Please <a href='. get_edit_post_link($value). '>click here</a> to edit this article as the Parent. Be Aware, this may switch blog sites.<br /> </div>'; 
      } 
      restore_current_blog(); 
     } 
    } 
} 

}

+1

請記住,也有wordpress.stackexchange.com,在那裏他們做的是關於面向WP-東西的步行路程。 –

+0

哦,太棒了,沒有意識到這一點。謝謝! – Greg

+1

你嘗試呼應'$ meta',看看它是否也越來越爲變量的回報? – Biotox

回答

0

我發現我的問題!唉唉。 $ post_id沒有被定義,直到頁面運行...我不得不將它更改爲$ _GET var。很抱歉謝謝!