WordPress 매개 변수를 통해 일부 템플릿을 읽는 방법
사용법
호출자
get_template_part( "articles", null, array( "title" => "タイトル" ) );
받는 사람
echo esc_html( $args["title"] );
여러 상황에서 array
만 추가하면 OKget_template_part( "articles", null, array( "title" => "タイトル","description" => "ディスクリプション" ) );
그나저나 버젼 5.5 이전 상황은 이렇게 적혀있어요.functions.php 등
쓰기
function get_template_part_args($template_name, $args = null) {
if (isset($args)) {
foreach ($args as $key => $value) {
set_query_var($key, $value);
}
}
get_template_part($template_name);
}
호출자
get_template_part_args( "articles", array( "title" => "タイトル" ) );
받는 사람
echo esc_html( $args["title"] );
set_query_var
의 함수는 다음과 같다.Reference
이 문제에 관하여(WordPress 매개 변수를 통해 일부 템플릿을 읽는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/shimomura/articles/24bc5ddef13e63780bef텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)