WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been searching for the answer on this, and still haven't found something that works. Could someone kindly let me know how to exclude the following code from all the picture attachment pages of Wordpress? This code is currently in my single.php file so that I can manage it from a central location. I don't know a whole lot about code so any information you can provide is greatly appreciated.

Thanks in advance!

`<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<p style="padding-left: 15px;"><a class="addthis_counter addthis_pill_style"></a>
&#x00A0;<a class="addthis_button_facebook_like" fb:like:layout="button_count">&#x00A0;</a>
&#x200B;<a class="addthis_button_tweet">&#x200B;</a>
<a class="addthis_button_pinterest_pinit"></a>
<class="addthis_toolbox addthis_default_style"> 
<a class="addthis_button_linkedin_counter" li:counter="none"></a>  
&#x00A0;<a class="addthis_button_google_plusone" g:plusone:count="false">&#x00A0;</a>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=xa-518895bb724be09b"></script>
<!-- AddThis Button END -->`
share|improve this question
up vote 1 down vote accepted

Not tried this myself, but try adding

<?php if ( ! is_attachment() ) { ?>
all your current stuff
<?php } ?>
share|improve this answer
Perfect! Thank-you so, so much as you have ended so much frustration for me! – user2376452 Jul 4 '13 at 21:01
If you are satisfied with the answer, please mark it as correct (click the tick) so other people know. – vancoder Jul 4 '13 at 21:04
Yes, thank-you, there was a mandatory waiting period, but I have it now! :-) – user2376452 Jul 4 '13 at 21:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.