Change the just-posted answer with Ajax : which file is it ?

5.74K viewsCore
0

Hi,

I added social buttons (Facebook etc) to share each answer, by adding code on answer.php.

The problem is that when somebody writes an answer, it is published with Ajax and the content of answer.php is not called, so the buttons do not appear automatically.

So there is another file I should edit to do that, apparently. Which one is it ?

 

Thanks for your answer !

Hello,
Will you please upload a screenshot so that I can know what you are pointing at.

0

I actually used

<div id="share<?php the_ID();?>"

so that is not what caused the bug 😉

I just noticed that if add html text inside this <div>, it works, the content appears on the just-posted answer, but if I add  PHP or social share buttons (which are Javascript) they don’t appear. Any idea why ? Thanks  🙂

commented on answer

May be syntax error.

0

Hello,

This is because you may using one css ID for all sharing buttons. Please use class instead of id or id like this:

id="answer_social_<?php echo the_ID(); ?>"
commented on answer
0

Sure  😉

Here you can see that in answer.php I added social sharing buttons on every answer, like in the upper one. But the answer that appears below, which has just been posted, has no social sharing buttons.

Thanks 🙂