• Resolved kingstakh

    (@kingstakh)


    I try load comments_template() when page is fully loaded. But have default form loaded, how call wpdiscuz form?
    My code functions.php

    function comm(){	 
      $p_id = ( $_POST['spd'] );	
      $args = array(
        'posts_per_page' => -1,
        'p' => $p_id
      );
      $yy_query = new WP_Query($args);	
      while ( $yy_query->have_posts() ) {
        $yy_query->the_post();
    global $withcomments;
        $withcomments = true;
         comments_template();		
      }	
     wp_die();
    }
    add_action('wp_ajax_mycomm', 'comm');
    add_action('wp_ajax_nopriv_mycomm', 'comm');

    Code single.php

    <script>
      var send_post_id = <?php the_ID(); ?>;
    </script>
    <div class="comment_template"></div>

    And Ajax:

    <script>
        $(document).ready(function(){	
     	$.ajax({ 		
     		url: ajaxurl, 
     		type: 'POST',		
     		beforeSend: (function(){				
              $('.comment_template').html('Loading..');
          }),
     		data: ({
     			action: 'mycomm',	
     			spd: send_post_id 			
     		}),
     		success: function(data){ 		 
     			$('.comment_template').html(data);
     		}
     	})
    });</script>
    • This topic was modified 3 years, 11 months ago by kingstakh.
    • This topic was modified 3 years, 11 months ago by kingstakh.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Call comments_template() after page is loaded’ is closed to new replies.