How to suppress Skimlinks for some content in WordPress

is a great way to moneterise a blog. Once signed up and approved you simple need to add a line of JavaScript to your site and it will add moneterised links to your output. However, you may be adding sponsored posts or your own links and may not want Skimlinks to modify the entire, or portion of, the post.

Simply open up your theme’s functions.php file and add the following lines…

function skim_suppress( $paras = '', $content = '' ) {
return '<div class="noskim">'. do_shortcode( $content ) . '</div>';
add_shortcode( 'noskim', 'skim_suppress' );
view raw functions.php hosted with ❤ by GitHub

Now simply use the new shortcode of noskim to suppress any post or page content.

For example…

[[noskim]This is a line about an iPhone at Dixons. I don't want any of the text to be linked to by Skimlinks[/noskim]]

Skimlinks provide a WordPress plugin that adds the appropriate code to your site. However, you can do this yourself, and improve upon it, by a few further lines added to your functions.php file…

function add_skimlinks_script() {
    echo "<!-- Skimlinks script -->n";
    echo "<script type="text/javascript" src=""></script>n";
    if ( ( !is_single() ) && ( !page() ) ) {
echo "<script>var noskim = 'true';</script>n";
add_action( 'wp_footer', 'add_skimlinks_script' );

This will add the Skimlinks script to your site’s footer – simply replace xxxx with your Skimlinks number. Additionally, this script is designed to only allow Skimlinks to be placed on single posts and pages – you can update this depending on your site’s requirements.

Lastly, you probably don’t want Skimlinks to appear on site parts of your site – e.g. the header, footer and sidebar. To suppress this you’ll need to have a bit more coding knowledge – identify the appropriate DIV that covers each area and add a class of “noskim” to it.

For example, say you have <div class="footer"> that covers the footer area of your site. If you change this to <div class="footer noskim"> then this will prevent any Skimlinks from appearing in the footer.

One reply on “How to suppress Skimlinks for some content in WordPress”

Thanks for this post – very helpful.

Just as an FYI, when you copy and paste the code above, it automatically adds your byline “Read more: Development, WordPress : How to suppress Skimlinks for some content in WordPress –” – so when I cut and pasted this into my functions.php file and quickly saved without checking it first, it broke my site! I had to go into my file manager and delete this line before my site would work again.

Thanks, Victoria

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: