전환 버튼을 사용하여 단축 코드를 실행하고 싶습니다. 스위치가 "ON"이면 단축 코드를 호출하고 "OFF"이면 다른 코드를 호출합니다.AJAX로 워드 프레스 단축 코드로 전화하십시오.
파일 "페이지 recherche.php":
<a href="" id="clicklien">CLICK HERE</a>
<script>
$("#clicklien").click(function(e){
e.preventDefault();
$.ajax({
url: 'http://www.capitainebar.com/wp-content/themes/Capitaine-Bar/shortcode-recherche.php',
success: function (data) {
// this is executed when ajax call finished well
console.log('content of the executed page: ' + data);
$('body').append(data);
},
error: function (xhr, status, error) {
// executed if something went wrong during call
if (xhr.status > 0) alert('got error: ' + status); // status 0 - when load is interrupted
}
});
});
</script
파일을 호출 내가 AJAX와 하나의 링크를 클릭에서 단축 코드를 호출 시도 테스트로
, 그것은 나에게이 있습니다 "shortcode-recherche.php"입니다.<?php echo do_shortcode('[search-form id="1" showall="1"]'); ?>
결과는 치명적인 오류입니다. 마치 코드가 "page-recherche.php"보다는 "shortcode-recherche.php"에서 실행되는 것처럼 말입니다.
단축 코드는 AJAX 호출없이 내 페이지에 직접 쓰면 잘 작동합니다. 직접, 워드 프레스가 포함되지 않은 PHP 파일을 호출 할 때
당신은 the result here
수신하는 오류를 게시 할 수 있습니까? – Dez
치명적인 오류 : /homepages/1/d543902707/htdocs/wp-content/themes/Capitaine-Bar/shortcode-recherche.php 온라인 1 –