내 Wordpress 게시물에서 속성 및 내용과 함께 단축 코드를 사용하고 있습니다. 이 단축 코드는 필자가 사용해야하기 때문에 필요합니다. 나는 색인 및 단일 페이지를 ajaxing입니다. 단일 게시물을 ajaxing하는 데 문제가 있습니다. 게시물 내용을 출력 할 때 클라이언트 측으로 리턴하면 단축 코드가 작동하지 않기 때문입니다.루프 밖에서 아약스 단축 코드 작업을 수행하는 방법
방법을 강요하는 것에 대한 제안 사항이 있습니까?
function ajaxsingle() {
global $wpdb;
$postID = $_POST[ 'postID' ];
$post = get_post($postID);
$postType = get_post_type($postID);
$slug = $post->post_name;
$title = get_the_title($postID);
$thumbnailUrl = wp_get_attachment_url(get_post_thumbnail_id($postID));
$excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $postID));
$sidebar = the_widget('post-inner-sidebar');
$post_content = $post->post_content;
$imgBackground = "../wp-content/themes/webdev/img/";
$imgBackground .= get_post_field('post_name', get_post($postID));
$imgBackground .= "_preview.jpg";
if ($postType == "articles" || $postType == "tutorials") {
$html = '<div id="blogWrap" style="background: linear-gradient(to right, rgba(255,255,255,0) 29%,rgba(255,255,255,0.9) 29%,rgba(255,255,255,0.9) 100%), url('.$imgBackground.'); opacity: 0;"><div id="articleHeader"><div id="headerLogo" style="background: url('.$thumbnailUrl.'), linear-gradient(to right, rgba(248,194,121,1) 0%,rgba(248,194,121,1) 100%)"></div><div id="excerptIntro"><div id="excerptInner"><h1>'.$title.'</h1><div class="leftQuotemark tutorials-leftQuotemark"></div><p>'.$excerpt.'</p><div class="rightQuotemark tutorials-rightQuotemark"></div></div></div></div><div id="blogInnerWrap"><div id="adContentWrap">'.$sidebar.'</div><div id="tutorialContent">'.$post_content.'</div></div></div></div>';
} else if ($postType == "case-studies"){
$html = '<div id="blogWrap" style="background: linear-gradient(to right, rgba(255,255,255,0) 29%,rgba(255,255,255,0.9) 29%,rgba(255,255,255,0.9) 100%), url('.$imgBackground.'); opacity: 0;"><div id="blogInnerWrap">'.$post_content.'</div></div></div>';
} else if ($postType == "software") {
$html = '<div id="blogWrap" style="background: linear-gradient(to right, rgba(255,255,255,0) 29%,rgba(255,255,255,0.9) 29%,rgba(255,255,255,0.9) 100%), url('.$imgBackground.'); opacity: 0;"><div id="softwareHeader"><div id="headerLogo" style="background-image: url('.$thumbnailUrl.'); ?>")></div><div id="excerptIntro"><h1>'.$title.'</h1><div class="leftQuotemark software-leftQuotemark"></div><p>'.$excerpt.'</p><div class="rightQuotemark software-rightQuotemark"></div></div></div><div id="blogInnerWrap">'.$post_content.'</div></div></div>';
}
echo $html;
wp_die();
}
postType이 일치하지 않으며 프런트 엔드에 html이 전송됩니다. 문제는 WordPress가 아약스 환경에서 단축 코드를 허용하지 않는다는 것입니다. 페이지의 전체 단축 코드를 텍스트로 인쇄합니다. 그러나 이러한 단축 코드는 시스템에 매우 중요하므로이를 구현하는 가장 좋은 방법을 찾아야합니다. –