see here 사이트에서 작업하고 있으며 "projects"라는 사용자 정의 게시 유형을 만들었습니다.
페이지가 처음로드 될 때 모든 것이 잘 작동하고 모든 게시물 데이터가로드됩니다. 그러나 $.load()
을 사용하여 외부 파일에서 동일한 코드를로드해도 아무 것도 표시되지 않습니다. 그것은 "post"(기본 유형)로 "프로젝트"를 "헬로우 월드"게시물에 다시 쿼리하지만 "프로젝트"는 제외하면 사용자 정의 포스트 유형에만 문제가있는 것으로 보입니다.jQuery.load()로 사용자 정의 게시 유형 쿼리
사용자 정의 게시 유형을 두 번 쿼리하려면 어떻게해야합니까?
<?php
\t $args = array(
\t \t 'post_type' => 'projects',
\t \t 'tax_query' => array(
\t \t \t \t 'taxonomy' => 'nonfiction'
\t \t \t)
\t \t);
\t $query = new WP_Query($args);
\t if ($query->have_posts()):
\t \t while ($query->have_posts()):
\t \t $query->the_post();
\t \t $meta_data = array(
\t \t \t 'author' => get_post_meta($post->ID, 'Author', true),
\t \t \t 'publisher' => get_post_meta($post->ID, 'Publisher', true),
\t \t \t 'year' => get_post_meta($post->ID, 'Year', true),
\t \t \t 'role' => get_post_meta($post->ID, 'Role', true),
\t \t \t 'location' => get_post_meta($post->ID, 'Location', true)
\t \t \t);
?>
\t <li>
\t \t <?php
\t \t \t echo $meta_data['author'];
\t \t \t echo ". ";
\t \t \t the_title();
\t \t \t echo " (" . $meta_data['location'] . ": " . $meta_data['publisher'] . ", " . $meta_data['year'] . "). " . $meta_data['role'];
\t \t \t
\t \t ?>
\t </li>
<?php
\t \t endwhile;
\t endif;
?>
$(document).ready(function(){
$('.tab').click(function(){
\t \t \t $('.publications').load('http://greyediting201.staging.wpengine.com/wp-content/themes/pp_boot/_nonfiction.php', null, console.log('finished'));
\t \t });
});
답장을 보내 주셔서 감사합니다. 코드를 상대 경로로 변경 했는데도 아무 것도 변경하지 않았습니다. 문제가 파일을로드하지 않고 해당 게시물을 두 번째로 표시하도록합니다. – dburgess923
– dburgess923
그래서 문제는 두 번째 시간이 아니라 한 번만 게시물을로드 할 수 있다는 것입니다. 그렇다면 우리는 이것을위한 해결책을 가지고 있습니다. 그리고이 Hello World 텍스트는 어디에서 오나요? –