쇼트 코드 내부의 쇼트 코드 - 워드프레스
종업원을 표시하는 쇼트 코드를 작성했습니다.HTML은 다음과 같습니다.
<ul class="employees">
<li><img src=""> <h5>name</h5> <p>description</p></li>
<li><img src=""> <h5>name</h5> <p>description</p></li>
..
</ul>
그래서 쇼트 코드를 2개 만들었습니다.
[start_filength] - 다음을 포함합니다.<ul class="employee"> .. </ul>
[contents] - 종업원에 대한 내용이 포함되어 있습니다.
다음과 같이 동작합니다.
[start_employee]
[employee img=".." name=".." description=".."]
[employee img=".." name=".." description=".."]
[/start_employee]
워드프레스 에디터에 넣으면 html은 다음과 같습니다.
<ul class="employee">
[employee img=".." name=".." description=".."]
[employee img=".." name=".." description=".."]
</ul>
왜 그런지 알 것 같아요start_functions의 함수는 다음과 같습니다.
return '<ul class="employee">'.$content.'</ul>';
숏코드로 읽히려면 어떻게 해야 하나요?
감사해요.
쇼트 코드가 자동으로 중첩되지 않음 - 전화해야 합니다.do_shortcode($content)네 자신.를 참조해 주세요.caption_shortcode()예를 참조해 주세요.
결과를 얻으려면 숏코드를 재귀적으로 사용해야 합니다.
function start_employee($attr,$content){
return '<ul class="employee">'.do_shortcode($content).'</ul>';
}
add_shortcode("start_employee","start_employee");
function employee($attr,$content){
return '<li><img src=""> <h5>name</h5>; <p>description</p></li>';
}
add_shortcode("employee","employee");
Cart66과 같이 재귀 함수를 설정한 경우 다음과 같은 작업을 수행할 수 있습니다.
echo do_shortcode('[hide_from level="membership" ]<strong>You may only order this item if you are a member. Become a <a href="http://yoursite.com/beta/member-log-in/">member</a>.</strong>[/hide_from]');
echo do_shortcode('[show_to level="membership"]'.do_shortcode('[add_to_cart item="'.$prefix.get_post_meta($post->ID,'_et_cart66_product_id',true).'" ]').'[/show_to]');
언급URL : https://stackoverflow.com/questions/4773186/shortcodes-inside-a-shortcode-wordpress
'programing' 카테고리의 다른 글
| 웹 사이트 하위 폴더로 다른 폴더 (0) | 2023.03.15 |
|---|---|
| Flexbox 레이아웃의 행 간 큰 간격 제거 (0) | 2023.03.15 |
| 아직 마운트되지 않은 구성 요소에서 setState를 호출할 수 없습니다. (0) | 2023.03.15 |
| Gradle > gradle boot Run으로 기동하는 Spring Boot 어플리케이션을 정지하는 방법 (0) | 2023.03.15 |
| jQuery를 사용하여 다른 포트로 AJAX 요청을 전송하려면 어떻게 해야 합니까? (0) | 2023.03.15 |