Custom content by country plug in

3
10
313 followers

Hi guys. I could do with some help. I've got the custom content by country plug in installed so the US see my .com affiliate links and the UK sees my .co.uk links. In posts and pages it works fine. In widgets it still filters content like it should, but it leaves the code visible to my site visitors. I've attached a screenshot to show you what I mean. Anyone know whats up?

3
10

Join FREE & Launch Your Business!

Exclusive Bonus - Offer Ends at Midnight Today

00

Hours

:

00

Minutes

:

00

Seconds

2,000 AI Credits Worth $10 USD

Build a Logo + Website That Attracts Customers

400 Credits

Discover Hot Niches with AI Market Research

100 Credits

Create SEO Content That Ranks & Converts

800 Credits

Find Affiliate Offers Up to $500/Sale

10 Credits

Access a Community of 2.9M+ Members

By continuing, you agree to our Terms of Service and Privacy Policy
No credit card required

Recent Comments

10

I did not know such a plugin was around lukas seems to have the solution, was it difficult to put right or would you say you need to know coding, I am not that great with code

If you follow Lukas' advice EXACTLY, nothing will go wrong. Bare in mind you might not even need to mess with the code. It depends on your theme.

Hey Katie!
You don't really have to mess with the code unless you encounter issues with short codes in widgets. The code provided here should work with any plugin that messes up your widgets with visible short codes (like on Hutch's screenshot) but is not needed if everything is ok.
The plugin we're talking about here is called Custom Content by Country, and you can download and install it straight from your WP dashboard.
It's a great free tool if you need to display a different content based on your visitors location (can be applied NOT only to Amazon affiliate links).

OK Hutch! Forget about my previous comment.
I found the solution for you.
You will have to edit your functions.php file and add this code:
"add_filter('widget_text', 'do_shortcode');"
without the quotation marks.
The reason you are getting this code visible on your website is not because there's something wrong with the plugin itself, or how you input the text in your editor.
It's because the WordPress is not parsing short codes in widgets by default ;)
When you add the provided code to your functions.php file you're basically enabling parsing for short codes in your widgets and those short codes are ran.
This is how to do it:
Go to your wp-admin dashboard, click on appearance, than editor. Find "Theme functions" tab on your right hand side, click on it. Add the code in "/***** Enable Shortcodes inside Widgets *****" section (just press ctrl+f - it will bring a small popup, type "widgets" in and it will find all text containing "widgets" in it on you site and highlight it, you can move from one part of the text to the other by clicking on an arrow in the popup), simply copy+paste the code in appropriate part of the file.

If you don't have this section in functions.php simply add this code to the file:

/***** Enable Shortcodes inside Widgets *****/

add_filter('widget_text', 'do_shortcode');

Make sure that the code goes before the last php tag (this is the tag: ?>) in the file.
Save the file, reload the page. If needed clear cache in your browser and check if it worked.
Check the image for reference - all steps are numbered on the image.
Hope it helps ;)

1

If I could like that more than once, I would! Thanks for your help Lukas, you're a diamond.

Hahaha :) you're more than welcome m8 ;) I hope it sorts the problem for you ;)

Does it matter where I paste
/***** Enable Shortcodes inside Widgets *****/

add_filter('widget_text', 'do_shortcode');

Make sure that the code goes before the last php tag (this is the tag: ?>) in the file.

1

Hi Hutch!
Can you please provide a screenshot of your editor in wordpress? All I need to see is the peace of text where you put your CBC code in. Thanks ;)

I wish I could help you but I will be watching for future updates on what to do

See more comments

Join FREE & Launch Your Business!

Exclusive Bonus - Offer Ends at Midnight Today

00

Hours

:

00

Minutes

:

00

Seconds

2,000 AI Credits Worth $10 USD

Build a Logo + Website That Attracts Customers

400 Credits

Discover Hot Niches with AI Market Research

100 Credits

Create SEO Content That Ranks & Converts

800 Credits

Find Affiliate Offers Up to $500/Sale

10 Credits

Access a Community of 2.9M+ Members

By continuing, you agree to our Terms of Service and Privacy Policy
No credit card required

2.9M+

Members

190+

Countries Served

20+

Years Online

50K+

Success Stories

The world's most successful affiliate marketing training platform. Join 2.9M+ entrepreneurs building their online business with expert training, tools, and support.

© 2005-2025 Wealthy Affiliate
All rights reserved worldwide.

🔒 Trusted by Millions Worldwide

Since 2005, Wealthy Affiliate has been the go-to platform for entrepreneurs looking to build successful online businesses. With industry-leading security, 99.9% uptime, and a proven track record of success, you're in safe hands.