Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
David

How to Use the Internal Link Count Filter

Hey guys,

I replied to a previous topic about this, but it was already marked as solved, so I’m guessing you didn’t see it. Here it is again:

I saw you guys added a filter for explicitly naming internal domains in your latest release, 4.1. I really appreciate it.

Would you mind providing a brief example of how I would go about using it? (I’m still very much a beginner with PHP)

My main website is https://wpsmackdown.com. I host my images on https://cdn.wpsmackdown.com, and when I link to them, can I exclude them from the link count? If not, can you show me how I would count these as internal and not external links?

Also, I cloak quite a few affiliate links: https://wpsmackdown.com/out/affiliate/. Is there any way to count any link starting with https://wpsmackdown.com/out/ as an external link?

Thanks for your help!
Dave

3 years, 8 months ago
Stefan
Developer

Hi Dave,

Sorry, I indeed did not see your reply on the ‘marked as solved’ issue before. As you already found out we introduced the ac/column/linkcount/domains filter. This filter allows you to say which domains are marked as ‘internal’. By default this function return an array which contains only the current domain of your website.

So in your case, you should add the ‘cdn.wpsmackdown.com’ domain to the array by using the following snippet.

/**
 * @param array $domains
 *
 * @return array
 */
function acp_add_internal_domains( $domains ) {
	$domains[] = 'https://cdn.wpsmackdown.com';

	return $domains;
}

add_filter( 'ac/column/linkcount/domains', 'acp_add_internal_domains' );

Please notice that this filter only allows you to add domains that are marked as internal. So it is not possible to count any links started with an internal domain count as an external link. So you really have to write your own column if you want to do that kind of logic since I don’t think this is the kind of behavior our link count column should support. Please let me know if you have any other question related to this filter.

Stefan

3 years, 8 months ago
David

Thanks Stefan. I spot checked a few posts, and this appears to be working perfectly.

3 years, 8 months ago
Stefan
Developer

Cool, thanks for the feedback!

3 years, 8 months ago

You must be logged in to reply to this topic.