I've been struggling to properly set up the AddThis Wordpress plugin to display share buttons below each post in an AJAX theme.
After inserting this code into the custom button field on the settings page:
<div class="addthis_toolbox addthis_default_style" id="toolbox">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
</div>
In the main page PHP file within the post loop, I have added the following script:
<script>
var tbx = document.getElementById("toolbox"),
svcs = {email: 'Email', print: 'Print', facebook: 'Facebook', expanded: 'More'};
for (var s in svcs) {
tbx.innerHTML += '<a class="addthis_button_'+s+'">'+svcs[s]+'</a>';
});
function ReinitializeAddThis() {
if (window.addthis) {
window.addthis.toolbox("#toolbox");
}
}
</script>
<iframe style="display: none;" onload="ReinitializeAddThis();"></iframe>
The share buttons tend to load inconsistently and vanish upon refresh. Additionally, I'm encountering an error message stating Uncaught ReferenceError: ReinitializeAddThis is not defined, which has me puzzled... Any assistance or clarification would be greatly appreciated. Thank you!