Info
- 31 posts
- 18 voices
- Started 5 years ago by kineda
- Latest reply from cwdnow
- This topic is not resolved
Add nofollow to links
-
- Posted 5 years ago #
Is there anyway to add the nofollow tag to links?
-
- Posted 5 years ago #
I would imagine that you could do this without affecting any core files through a plugin as the links portion for posts is pluggable. Now, saying that, we need someone with some experience working with the code to make this a plugin.
Trent
-
- Posted 4 years ago #
Please--can you tell me specifically where to add this? What file and which lines? (Sorry, perpetual noob, trying to learn.) :-)
-
- Posted 4 years ago #
You can simply add that line into
bb-includes/default-filters.php
or
create your own plugin file with that line. -
- Posted 4 years ago #
livibetter, for us noobs, can you show what a plugin would look like with just that functionality, so we could avoid modifying a core file in bb-includes?
Thanks.
-
- Posted 4 years ago #
Here it is:
<?php /* Plugin Name: My own tweak for my forums Plugin URI: http://bbpress.org/ Description: Fine tuning codes for my forum Author: Your name Author URI: http://www.myforum.com/ Version: 0.1 */ add_filter('post_author_link', 'bb_rel_nofollow'); ?>Basically, you can put many fine tuning codes within one PHP files, and this file is for your forum only. Remember to activate this plugin.
-
- Posted 4 years ago #
If it were a _plugin, would it load automatically, and not require activation? Like, you could call it _myforumtweaks.php and it would be loaded automatically with no activation once you dropped it into my-plugins?
That's all there is to a simple add_filter plugin, eh? (no video required...)
-
- Posted 4 years ago #
livibetter,
Thanks so much! It works beautifully.
I know it works on new posts, on URLs in the post.
Does it also work on URLS in old posts, when they're viewed? I am not able to test that.
Also, it obviously doesn't work on author's website links (the ones saves in their user profile, I mean). How do we make those nofollow if we want to?
Many, many thanks. I am learning, but slowly.
-
- Posted 4 years ago #
Okay, upon further testing, it does seem to be working with older posts--in certain circumstances.
Let me explain
If you simply type (or in the past typed) in a URL, this plugin adds "nofollow." But if you write a sentence and add a link to the text, it doesn't. You can see this in effect here:
http://bedbugger.com/forum/topic/test-5?replies=3#post-14812Compare the two tests of a link to google. The first, where the URL is typed in, adds nofollow, the second, where the HTML is used to link out to google, doesn't.
Please help me fix this? Thanks again, this is a huge help!
-
- Posted 3 years ago #
It works great.. but a savvy spammer can bypass this simply by editing their post and adding rel='follow' to their a tag.. anyone know of a more complete/thorough solution?
-
- Posted 3 years ago #
It worked fine with me, I'll just manually delete the entry of the spammers! :)
-
- Posted 3 years ago #
Try manually deleting a few hundred posts per day once you get popular..?
Anyone know of more thorough solution? One that permanently adds "nofollow" to all posted links??
-
- Posted 3 years ago #
I thought this plugin did that?
http://bbpress.org/forums/topic/add-nofollow-to-links#post-12523 -
- Posted 3 years ago #
Hi there,
I have tried so hard to tweak this plug in but I am unable. All I want is to add besides the nofollow is a target="_top" so that the forum user is able to go out to another window for external links.
Can anyone help me please,
Many thanks,
-
- Posted 3 years ago #
by default the nofollow is there, but how can we add some more things to the tag?
-
- Posted 3 years ago #
cordoval, make this into a plugin:
//add target=_blank to post links function bb_target_blank( $text ) { $text = preg_replace('|<a (.+?)>|i', '<a target="_blank">', $text); return $text; } add_filter('pre_post', 'bb_target_blank'); -
- Posted 3 years ago #
the problem was that it was not 'post_author_link but 'post_text
-
- Posted 2 years ago #
cordoval did you get it to work with links in text also? Not just URLs.
Thanks. -
- Posted 1 year ago #
I know this post is rather old, but none of the above suggestions worked. The problem with using the post_author_link or even get_user_link filters is that those only filter the "href" attribute, not the entire "a" tag. That means you can't add rel="nofollow" using those filters.
I wasn't able to figure out a way to get it done without editing the core. I suggest the post_author_link() function around line 1747 of bb-includes/functions.bb-template.php be edited to allow the option of only returning the link rather than echoing it. That way, you can output the author links in your template (post.php) using something like this:
<?php bb_rel_nofollow(post_author_link(false)); ?>With the "false" parameter telling WordPress to return the link rather than echo it. I believe that would work for future releases.
As for now, I believe you'll have to open bb-includes/function.bb-template.php and edit the post_author_link and post_author_avatar_link functions to add rel="nofollow" to the "a" tags. Those functions begin around line 1747 of bb-includes/function.bb-template.php.
Hope that helps.
-
- Posted 1 year ago #
Better yet, nofollow should be the default rel attribute value. From an SEO standpoint, you're asking for trouble allowing dofollow links unless you really feel like checking out every single users' website and making sure it's not a "bad neighborhood". Even then, Google will see you as handing out links indiscriminately and will probably take away any pagerank your pages might have had.
-
- Posted 1 year ago #
jcrens8392, if you would like this included in future versions, please open a ticket at trac: http://trac.bbpress.org - you can log in there with a wordpress.org username and password.
-
- Posted 1 year ago #
Hi,
since i have the forum in a different frame of my page, i'd have to add the attribute "target_top" to every link.
The code below is only for target_blank, or would it be possible to replace every "blank" with "top" and have it working?
----------------------------------------------------------------------------
http://bbpress.org/forums/topic/add-nofollow-to-links#post-17523"
----------------------------------------------------------------------------And how do you make the code into a plugin? you copy and paste into a text file, save it as *.php and upload the file in the bbpress plugins folder?
Thank you very much, every help is very appreciated!
The Process
-
- Posted 1 year ago #
If you want all links in your posts to be nofollow, you have to use post_text instead of post_author_link
Here you go
<?php
/*
Plugin Name: My own tweak for my forums
Plugin URI: http://bbpress.org/
Description: Fine tuning codes for my forum
Author: Your name
Author URI: http://www.myforum.com/
Version: 0.1
*/add_filter('post_text', 'bb_rel_nofollow');
?>I guess that's what most people want to do
-
- Posted 1 year ago #
thank you! thank you!!!!! works perfectly :)
-
- Posted 1 year ago #
I don't think adding nofollow tag is a good idea on your site. For a forum, dofollow feature will give you many original contents.
-
- Posted 1 year ago #
This is driving me crazy. I cannot get any of the target="_blank" or "nofollow" plugins to work. I'm using the default kakumei theme with the latest WordPress installation. Has the plugin code changed?
-
- Posted 1 year ago #
hi ya'll
I am sorry I was not back earlier on this post but I have managed to solved everything without touching the core and my method is extensible to whatever you want to do.
//add target=_blank to post links
function bb_target_blank( $text ) {
return preg_replace_callback('||i', 'bb_target_blank_callback', $text);
}
function bb_target_blank_callback( $matches ) {
$text = $matches[1];
return "";
}add_filter('post_text', 'bb_target_blank');
If you require further support then you can always reach to me at cordoval at gmail dot com and you can send me a small token of your appreciation via paypal. Thanks.
-
- Posted 1 year ago #
all the code got messed up while posting on here, I wrapped it between
but would not work properly someone does know how to make it look pretty? -
- Posted 1 year ago #
@ant123
http://bbpress.org/forums/topic/add-nofollow-to-links#post-74079
works for me andhttp://bbpress.org/forums/topic/nofollow#post-58232 is work for me too (bbsignatures)
and all links is nofollow now. Thanks