나는 "Portfolio"라는 게시물 유형과 그것을 처리하기위한 단일 portfolio.php 파일 (WordPress)을 가지고있다. 이 예상처럼 작동 그렇게 내가 뭔가를 사용하는 경우 :WordPress - 원래 WP_Query 복원
$post_id = $post->ID; //returns ID of current portfolio post. Good!
을하지만 중간에이 같은 짧은 쿼리를 게시 할 때 :
$post_id = $post->ID; //returns ID of current portfolio post. Good!
wp_reset_query();
query_posts('posts_per_page=4');
if (have_posts()) : while (have_posts()) : the_post();
the_id(); //returns ID of standard blog post
endwhile;
endif;
wp_reset_query();
$post_id = $post->ID; //returns ID of last BLOG post. Wrong!
을 나는 위의 예에서 $post_id
변수에 대한 유일한 걱정. 현재 PORTFOLIO 게시물의 올바른 ID를 항상 반환하고 다른 쿼리에 의존하지 않기를 바랍니다. 어떻게해야합니까?
나는 $ temp = $ post로 그것을하는 방법을 발견했다; $ post = $ temp; 쿼리 후에는 공식 및 권장 방법이라고 생각하지 않습니다. – Atadj