2017-10-10 79 views
0

我寫了一個函數,該函數與'wp'鉤子一起運行,並在滿足特定條件(使用高級自定義字段)時重定向,但僅在登錄時才起作用。吐出一個太多的重定向錯誤退出時重定向循環僅

function swa_wc_product_redirect_to_post(){ 
    if (is_product()) : 
     if (get_field('redirect_to_post') == 1) : 
      $redirect_post_url = get_permalink(get_field('redirect_post_id')) ; 
      wp_redirect($redirect_post_url , 301); 
     endif; 
    endif; 
} 
add_action('wp','swa_wc_product_redirect_to_post'); 

任何想法,爲什麼它僅在註銷時循環?也許我錯過了一些簡單的東西。

回答

0

哇 - 需要在這個項目上;-)

原來的職位,它試圖重定向到被設定爲私人休息 - 因此循環。