Jump to content


Photo

Javascript loading on boxes (Facebook Like and others)


This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1 rsutton1223

rsutton1223

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 08 November 2010 - 12:34 AM

When I activate Digg Digg floating sharing buttons or the Facebook Like plugin, it not only shows up on the article I want it to, but it also shows up for the three boxes I have displaying above each article. Is there a way to keep scripts for loading on the boxes as if they were single posts?

#2 catrina

catrina

    Advocate

  • Members
  • 12345 posts

Posted 08 November 2010 - 12:52 AM

Can you send a link to your website so I can see what it looks like?

#3 rsutton1223

rsutton1223

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 08 November 2010 - 01:03 AM

http://www.bloggingl...t-online-brand/

#4 catrina

catrina

    Advocate

  • Members
  • 12345 posts

Posted 08 November 2010 - 02:46 AM

Hm, try deactivating the other plugins you have.

#5 onlinetracker

onlinetracker

    Super Member

  • Members

  • 154 posts

Posted 08 November 2010 - 03:24 AM

Robb, I'm in the same boat. I have a plugin that bleeds into the pages, features, and boxes from PlatformPro. I was told it was the plugin, not the theme. Although it may not be entirely the same (it looks exactly the same type of display/process), I have to wonder what the fix is. I don't have this problem with other themes/frameworks.

#6 rsutton1223

rsutton1223

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 08 November 2010 - 11:16 AM

Deactivating other plugins isn't going to fix that issue. For some reason, it is allowing the script to load on each of those boxes treating them as articles. Ideally, I would like the boxes and other page elements that are setup within the Wordpress admin like pages and articles to be excluded from loading scripts like these. In the meantime, I can hard code the buttons I want into the top and bottom of the article, but the floating feature does convert better.

#7 cmunns

cmunns

    Advocate

  • Members

  • 6537 posts

Posted 08 November 2010 - 08:59 PM

Looking at the facebook like plugin they use this hook to append the function to the theme `add_action('the_content', 'simple_facebook_like');` the_content, however, is obviously used to display the content of any post type like pages or posts and the features,boxes, etc. You can edit the plugin file to only allow a certain post type like this ` function simple_facebook_like($the_iframe = '') { if (get_post_type() == 'post'){ $the_perma = rawurlencode(get_permalink()); $the_iframe .= '
'; return $the_iframe; } } ` I edited the function to include an if statement so it only shows on posts. You would have to add something else for it to be on pages as well

#8 onlinetracker

onlinetracker

    Super Member

  • Members

  • 154 posts

Posted 09 November 2010 - 01:50 PM

Adam,

You can edit the plugin file to only allow a certain post type like this


That is easy for YOU to say.

/facepalm

Would you mind telling me what to look for to limit a plugin from adding content to custom pages like the Features, Boxes, etc? Although I can't see it [and I'm afraid to actually go looking at the source code], I'm sure that a plugin I have is also loading a ton of data into every Feature [I can see that one] and every box and every banner.

#9 rsutton1223

rsutton1223

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 11 November 2010 - 02:12 PM

Anything else on this? I would rather not hack up plugin files...

#10 cmunns

cmunns

    Advocate

  • Members

  • 6537 posts

Posted 11 November 2010 - 09:09 PM

Did you look in the plugin file? There is only one file and the code I pasted above is about the lot of it. I have given you all you need and tested it as well.

#11 rsutton1223

rsutton1223

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 12 November 2010 - 12:55 PM

The issue is that it is not just one plugin. Any plugin that runs javascript on a post shows up for those boxes. Digg Digg is another example. There has to be a way to do it in the theme and not on the plugin as people are going to run into this issue a lot. I do not want to hack up plugins.

#12 cmunns

cmunns

    Advocate

  • Members

  • 6537 posts

Posted 12 November 2010 - 06:56 PM

The theme is already correctly coded as it identifies custom post types as such the problem is that plugin authors may have not taken this into consideration. Most of the time they use the WP hook "the_content" to append appropriate code which doesn't discern between post types at all. For example the "Digg This Button" plugin seems to take these options into consideration and I recommend trying that instead.