How to add unique meta description tags in WordPress without plugins

When I checked my website for errors in the Google Search Console earlier this morning, I noticed a warning about duplicate meta descriptions on my WordPress website. I had 205 pages with duplicate tags and at first I didn’t think much of it, but I decided to find out the significance in terms of better SEO just in case. I was shocked to realise that having duplicate meta description tags throughout your WordPress blog is a bad idea and Google doesn’t like it one bit!

Google: Don’t duplicate meta description tags

Google’s Matt Cutts has officially stated in his video that it’s better to have no meta description tag than to have numerous duplicate meta description tags on all of your pages and categories. This is especially frustrating because by default most WordPress templates have only the one description tag displayed throughout the entire website. Check out this video with Matt explaining everything:

Unique meta description without plugins

It’s clear that Google doesn’t endorse the use of duplicate description tags and there are numerous plugins available that try to work around it (YOAST for example) and while I don’t personally have anything against these plugins, one might still consider avoiding them in order to gain better website loading speeds because it’s common knowledge that having too many plugins active on your WordPress site can actually slow down the loading speeds and make the end user experience that much more annoying.

Just a few lines of code

In your header.php file remove the default <meta name=“description” content=“Your description”/> and instead use the following code:

<?php if ( is_home() ) { ?>
<meta name="description" content="Your main and most important description shown on homepage"/>
<?php } ?>
<?php if ( is_single() OR is_page() ) { ?>
<meta name="description" content="<?php { setup_postdata($post); echo esc_attr(htmlentities(get_the_excerpt())); } ?>"/>
<?php } ?>

The above code uses conditional statements to check whether the currently displayed page is either a homepage, a single post or a single page and then uses “Your main and most important description shown on homepage” on your homepage and the default post excerpt in the description of posts and pages respectively.

In my experience you don’t really need to display the description tag anywhere else so I removed it from elsewhere. And in case you’re worried, Google is fairly good at coming up with descriptions for the rest of your page so your search results should still look very nice.

Double check just in case

This code works on my template, but you should still double check so after editing the header.php and replacing it with the original try refreshing your page (ctrl + F5) and then view the page source, especially the meta description tag, and see if it’s working. First try it on the homepage (main index) and then click on any posts or pages you may have and view the source on those pages also. If you see the post excerpt inside the description tag it means everything is working as it’s supposed to.

Share!

How to kill the King Black Dragon in Runescape Evolution of Combat (EOC)

The King Black Dragon

The King Black Dragon (KBD) is one of the easiest bosses in Runescape, but it can still be a formidable opponent for a low level player like myself.

King black dragon from RunescapeTo successfully kill the KBD at least 2-3 times before going to the bank for supplies you will need at least level 80+ in both Defence and Magic, assuming of course you are using magic to slay this monster.

Items to bring:

  • Either anti-fire shield or dragonfire shield
  • Antifire potion or a flask
  • The best armor you can wear
  • Monkfish or better for food
  • A panic teleport tab will be useful!
Share!
Filed under: Runescape, VideosTagged with: , , , , ,

How to make a closable hover header div for your website announcements or ads using CSS and Javascript

html and css programming language pictureIt’s perfect for site news

In this tutorial you will learn how to make a “hovering” header for your website news, announcements or ads. I am currently using the same technique on this blog too and it should have loaded up by now. (not any more!) As you can see it can be easily closed by the red X button and it’s “hovering” over the main content so it keeps showing even when your users scroll down.

The requirements

This script uses Font Awesome and jQuery via CDN. This basically just means that you need to add the following code inside your <head></head> tags:

<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">

The HTML and CSS parts

This will be the face for your news box and you can customize things like font size, background color, padding, etc. Add the following code right after your opening <body> tag:

<div id="announcement">
 <span id='message'>Your message goes here. You can add a link if you want or whatever you like.</span>
 <span id='close'><a href="#" title="Close"><i class='fa fa-times'></i></a></span>
 <div id="delimiter"></div>
 </div>

* I’m using the delimeter div to clear both floats so it will not cause any styling errors.

Here is my CSS

Customize it to fit the design of your website!

#announcement {
    padding: 0;
    margin: 0;
    display: none;
    background: #CCFF99;
    height: auto;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
 z-index: 9999;
}
#message {color: #000; font-size: 1em; float: left; padding: 0 2.1% 0 2.1%;}
#close {position: fixed; top: 0; right: 0; padding: 0 2.1% 0 2.1%;}
.fa-times {color: red;}
#delimiter { clear: both; }

* The position: fixed; along with top: 0; and left: 0; are what make the div hover over the main content. Same goes for the close button- just replace left with right to put it on the top right side of your page.

* z-index is a useful property because it specifies the stack order of an element. By giving it an unrealistic value we make sure it will stay on top of every possible element on your page.

* I’m using display: none; so that it will only display after Javascript has determined that the page is fully loaded.

* The fa-times class is for our close button. Font Awesome is really awesome ;)

Finally the Javascript

This is what makes everything work nicely! Add this code inside your <head></head> tags:

<script>
 window.onload = function () {
 document.getElementById('close').onclick = function(){
 this.parentNode.parentNode.removeChild(this.parentNode);
 return false;
 };
 }
 $(document).ready(function() {
 $("#announcement").delay(2000).fadeIn(500);
 });
 </script>

* I use the window.onload function to execute the script only after the whole page has finished loading. If your user is waiting for the page to load and at the same time a news box appears, it might scare away a potential client.

* You should also notice the getElementById(‘close’) and $(“#announcement”). Do not change these, they are the ID’s of the close button and the news box itself.

Share!

How to add a Read More link on your content when someone copy pastes it

Everyone copy pastes!

Every day people copy and paste paragraphs, quotes and anything else you can imagine from one place to another online. Copy pasting has become one of the most common elements of social media as well because we all love to share something we think is cool with our friends. When was the last time You copy pasted something? Chances are you still have that data on your clipboard.

Get backlinks on copied content

How to add copyright read more link back to your site on copy paste text
At this very moment hundreds of thousands of people are sharing something via email, social networks, blogs and messenger apps by copy and pasting information. Wouldn’t it be awesome if your website would somehow automatically add a read more link along with the text that someone copies from your site?

It turns out there is an incredibly easy way to do this! All you need to do is add the following code just before your closing head tag. (it looks like this: </head>)

 

Copy and paste this code:

<script>
 function addLink() {
 //Get the selected text and append the extra info
 var selection = window.getSelection(),
 pagelink = '<br /><br /> Read more at: ' + document.location.href,
 copytext = selection + pagelink,
 newdiv = document.createElement('div');
//hide the newly created container
 newdiv.style.position = 'absolute';
 newdiv.style.left = '-99999px';
//insert the container, fill it with the extended text, and define the new selection
 document.body.appendChild(newdiv);
 newdiv.innerHTML = copytext;
 selection.selectAllChildren(newdiv);
window.setTimeout(function () {
 document.body.removeChild(newdiv);
 }, 100);
 }
document.addEventListener('copy', addLink);
</script>

I’ve turned the part that you can modify yourself red within the code so it’s easier to see. Just change that to whatever you like or remove it altogether to only have a link under the copied text. It’s up to you! The only thing you should keep are the <br /> tags otherwise the link will be added on the same line as the copied text and it makes it kind of annoying.

Note: I didn’t come up with the code myself. The original article can be found on StackExchange

Share!

[DIY] – How to cure stress and mild depression in just 30 days

Stress reduction exercise – how to deal with stress

NB! Once you start actively doing this, some people, especially your loved ones, can easily misinterpret this activity as obsessive compulsive disorder. Kindly refer them to this article to explain what it is that you are doing!

Requirements:

1 pencil

30 sheets of paper

Optional:

Blue, yellow and red colored pencils

The method

The method is actually pretty straightforward. Starting from today, take one of your sheets of paper and draw a circle in the middle of the paper. When you have done that it’s time to fully color the inside of your circle. The trick is to try and draw a perfect circle by hand without using any special tools whatsoever. The more time you spend drawing and perfecting your circle, the better the end result! Use a new sheet of paper every day.

How to cure stress and stress reduction tricks

What is this nonsense?

A circle is an object that represents fullness and completion. When you are drawing a circle you are effectively reprogramming your brain into thinking about this which in turn makes you feel fulfilled and complete. In order to REALLY max out the effect, it’s important to fill the inside of your circle otherwise you might start feeling emptiness in a very short time.

It takes about 5-10 days to “kick in”. You will not notice the change at first and in the beginning it will most likely feel very tedious and stupid drawing circles every day. Don’t give up! It’s perfectly normal to feel this way because over the years we have built ourselves certain behavior patterns that society considers to be the norm and our brain is trying to weed out everything odd and peculiar. In reality when you really think about it, drawing circles every day doesn’t necessarily make you insane so there is no need to feel this way. Your brain just tries to tell you this in order to fit into the common social mechanism. It’s kind of like self preservation really.

Tips

It’s best to draw a circle with a diameter of at least 2 cm, the bigger the better. If your circle is too small your brain doesn’t have enough time to really get into the “mood” and it will dismiss it as something unimportant.

It’s better if you do this in the morning as you’re eating breakfast or drinking your coffee. This way your whole day will feel a little bit better. By the way, try to not drink more than one cup of coffee every day.

If you happen to have blue, red and yellow colors then you can even change the way your entire day will unfold! Simply paint the circle blue if you want to have a relaxing and calm day. Red if you need to be successful in something (job interview, exam etc.) or yellow if you need to stay friendly (going out with friends).

Don’t stop after 30 days! While one month should be enough for the average person, it can sometimes take a little bit longer. We are all different after all. And even if you are feeling like a whole new person after a month, you still don’t have to stop. When you continue doing this, you will make sure these effects are not fading away over time. You will start feeling so good that you can’t help but tell others about this too!

A good idea is to go jogging or simply take a walk outside for at least 15 minutes after you have drawn your circle for the day- this is what’s actually important in all this, lol :P

Share!