Archived

This topic is now archived and is closed to further replies.

  • 0

Javascript loading on boxes (Facebook Like and others)

Question

Posted · Report post

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?

Share this post


Link to post
Share on other sites

11 answers to this question

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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

Share this post


Link to post
Share on other sites

Posted · Report post

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

Share this post


Link to post
Share on other sites

Posted · Report post

Hm, try deactivating the other plugins you have.

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites

Posted · Report post

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

Share this post


Link to post
Share on other sites

Posted · Report post

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.

Share this post


Link to post
Share on other sites