The effects of alcohol on sustanon 250 leucine for – real weight loss & bodybuilding benefits?
Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Call comments_templ...
 
Share:
Notifications
Clear all

Call comments_template() after page is loaded

7 Posts
2 Users
3 Reactions
1,850 Views
Posts: 7
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@kingstakh)
Active Member
Joined: 6 years ago
[#1485]

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>

6 Replies
Asti
Posts: 8210
 Asti
Support
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@asti)
Illustrious Member
Joined: 8 years ago

Hi @kingstakh,

If you create a global $post object correctly, it should work fine.

Also please don't duplicate the questions. Just open a new support topic here. 


Reply
Posts: 7
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@kingstakh)
Active Member
Joined: 6 years ago

 

defaultform

Now rendered default Wordpress form

Posted by: @asti

If you create a global $post object correctly, it should work fine.

What is mean?


Reply
4 Replies
Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8210
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@kingstakh,

Please wait a bit. You'll be answered soon. The developers will try to modify the code and help you with this. 


Reply
Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8210
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@kingstakh,

Below is provide the code. Use this one instead of the code you've put in the functions.php file. 

 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();
        $wpdiscuz = wpDiscuz();
        $wpdiscuz->form = $wpdiscuz->wpdiscuzForm->getForm(get_the_ID());
        add_filter("comments_template", [&$wpdiscuz, "addCommentForm"], 9999999);
      global $withcomments;
      $withcomments = true;
      comments_template();
   }
   wp_die();
}
add_action('wp_ajax_mycomm', 'comm');
add_action('wp_ajax_nopriv_mycomm', 'comm');

Please note if you use the code, the rich editor will not be loaded. So you will be able to use only the textarea. 


Reply
(@kingstakh)
Joined: 6 years ago

Active Member
Posts: 7
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@asti thank you, now work nice. But have some little issue, when use Rich Editor in plugin setting form rendered with wpd-editor-wraper style display:none. Without Rich Editor all is ok.

diplaynone

 


Reply
Asti
 Asti
Support
(@asti)
Joined: 8 years ago

Illustrious Member
Posts: 8210
Asti
Asti
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@kingstakh,

Please note if you use the code, the rich editor will not be loaded. So you will be able to use only the textarea. 

I've already mentioned this in my answer. 


Reply
Share: