1
私はcustomize_registerの作用の下で、現在のqueried_objectのIDを取得しようとadd_action下のポスト、ページまたは分類IDを取得する方法( 'customize_register'、...) - WP ...
// call action customize register
add_action('customize_register','register_customize_options');
//customize register callback function
function register_customize_options($wp_customize){
//if is page customize preview
if(is_page()): //not work
$ObjID = get_the_ID(); //not work
//if is any taxonomy customize preview
elseif (is_tax()) : //not work
$ObjID = get_queried_object()->term_id; //not work
endif;
// obj $wp_customize;
// var_dump($wp_customize); //not found any ID
//rest of code...
}
をカスタマイズまた、私は取得してみてくださいページIDはurl_to_postid($_GET['url'])
で、これはユーザーがページ上でカスタマイズを開いた場合にのみ機能します。
どのように動的にオブジェクトIDを取得するには、customize_registerアクションの下で?
ありがとうございましたが、それは私にとってはうまくいきません。 あなたはWPのインストールでそれを試していますか? –