2012-09-07 4 views
0

3 가지 게시물에 대해 동일한 댓글을 표시해야하는 독특한 상황이 있습니다. 이 3 가지 게시물은 분명히 DB에 링크되어 있습니다. 그래서 내가해야 할 일은 모든 언어에 대해 1 개의 게시물 ID를 사용하여 코멘트를 제출하고 검색하는 것입니다. 3 개의 diff ID 대신 1을 사용해야합니다.wordpress : 다른 게시물에서 단일 게시물에 댓글을 표시하는 데 문제가 있습니다.

$ current_post_duplicate_id는 3 개의 번역 된 게시물 모두에 대해 9입니다.

원래 post_ID 9 인 원래 게시물에 대한 의견을 제출하면 모두 정상적으로 작동하므로 의견이 표시되고 제출됩니다. 하지만 번역 된 버전으로 전환하면 아무 것도 표시되지 않지만 get_comments가 $ current_post_duplicate_id를 통해 주석을 표시하고 제출하기 위해 id 9를 사용하도록 강제하고 있습니다. 그래서 무슨 일이 일어나고 있습니까? 왜 이것이 작동하지 않는거야 ??

나는 어떤 일이 일어나고 있는지 알 수 없다. 나는 여기 몇몇 전문가들이 나에게 힌트를 줄 수 있다고 생각했다.

<?php 
//Uniting comments in all languages by setting default language for comments en in this case 
$current_post_duplicate_id = icl_object_id (get_queried_object_id(), 'tribe_events', false, 'en'); 
?> 






          <div id="eventattend"> 

            <?php if ('open' == $post->comment_status) : ?> 
            <span><?php _e('Are you intersted?'); ?></span> 



            <?php if ($user_ID) : ?> 


<?php 
    $usercomment = get_comments(array('user_id' => $current_user->ID, 'post_id' => $current_post_duplicate_id)); 
    if (1 <= count($usercomment)) { 
?> 
               <form method="post" action=""> 
                <a class="eventno" href="javascript:;" onclick="parentNode.submit();"><?php _e('No'); ?></a> 
                <input type="hidden" name="delmycom" value="1" /> 

                <?php 
                // 
                $delete_my_event_interest = $_POST['delmycom']; 
                 // 
                 if (isset ($delete_my_event_interest)) { 

                  $current_user_comment = get_comments(array(
                   'post_id' => $current_post_duplicate_id, 
                   'user_id' => get_current_user_id(), 
                   'number' => 1, 
                   'status' => 'approve', 
                   'type' => 'comment' 
                  )); 

                 wp_delete_comment($current_user_comment[0]->comment_ID); 
                 } 
                 // 
                ?> 
               </form> 
<?php } else { ?> 
               <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post"> 
                <?php comment_id_fields(); ?> 
                <?php do_action('comment_form', $current_post_duplicate_id); ?> 
                <input type="hidden" name="comment" value="I'm attending this Event!" /> 
                <a class="eventyes" href="javascript:;" onclick="parentNode.submit();"><?php _e('Yes'); ?></a> 
               </form> 
<?php } ?> 


            <?php else : ?> 
             <a class="eventyes loginosx" href="#"><?php _e('Yes'); ?></a> 
             <?php _e('*You need to be loged in to say YES.'); ?> 
            <?php endif; ?> 





            <?php endif; // if you delete this the sky will fall on your head ?> 

            <div class="clearfloat"></div><!-- Very Important --> 
          <!-- End #eventattend --></div> 



        <!-- End #eventsingle --></div> 










        <ul class="sidebarlists" id="interestedlist"> 
         <li> 
         <h2><?php _e('Who\'s interested so far?'); ?> (<?php comments_number('0', '1', '%'); ?>)</h2> 
         <ul> 

            <?php 

            $recent_comments = get_comments(array(
             'post_id' => $current_post_duplicate_id, 
             'number' => 25, 
             'status' => 'approve', 
             'type' => 'comment', 
             'order' => 'ASC' 
            )); 

            foreach ($recent_comments as $comment) { 
            ?> 
             <li id="attendee-<?php echo $comment->comment_ID; ?>"> 
              <a href="#"><?php echo get_avatar($comment->comment_author_email, $size = '50', $alt = $comment->comment_author.' is attending this event'); ?></a> 
              <span><?php echo $comment->comment_author; ?></span> 
             </li> 
            <?php 
            } 
            ?> 

         </ul> 
         </li> 
        <!-- End #sidebarlists --></ul> 

답변

0

사용 당신은 또한 다음과 같은 매개 변수를 전달할 수 있습니다

<?php $comments = get_comments(array('post_id' => 1)); ?> 

<?php $defaults = array(
    'author_email' => '', 
    'ID' => '', 
    'karma' => '', 
    'number' => '', 
    'offset' => '', 
    'orderby' => '', 
    'order' => 'DESC', 
    'parent' => '', 
    'post_id' => 0, 
    'post_author' => '', 
    'post_name' => '', 
    'post_parent' => '', 
    'post_status' => '', 
    'post_type' => '', 
    'status' => '', 
    'type' => '', 
    'user_id' => '', 
    'search' => '', 
    'count' => false, 
    'meta_key' => '', 
    'meta_value' => '', 
    'meta_query' => '', 
); ?> 
관련 문제