Site icon League WP

How to Add Twitter Cards to Genesis Theme (WordPress)

When you share your blog posts on Twitter, you want to showcase your blog posts in all its glory – the title, description and large feature image. If you’re reading this post, chances are you’re already familiar with the Twitter Cards. Although there are many plugins available to add Twitter Cards to WordPress websites, a plugin approach is for those who are not familiar with coding. The thumb rule is that if there’s something you can achieve via adding a piece of code to your functions.php, you should avoid the plugin alternative.

Although plugins are easy to install and activate, you usually pay a price for taking the easy route – it slows down your website loading time by increasing the number of requests. Plus, a poorly coded plugin renders your site potentially vulnerable to hackers.

Of course, I am a big fan of doing everything via adding coding snippets even if that means having a painfully long functions.php file.

Anyway, here’s how you can add Twitter Card meta data to your WordPress blog via adding code snippets to your functions.php file.

Although this tutorial is based on adding Twitter Cards to a Genesis theme, it still works for any WordPress themes. However, if you’re new to WordPress development, I’d advise you should create a child theme before adding code to your site.

Note: I’m assuming you’re familiar with how to work with a FTP client, e.g, FileZilla. If you’re not, take the easier route – install a suitable plugin.

If you’re familiar with FTP, please proceed and open your functions.php file and add the following code to the end of your file.

Save your file and then go ahead and enter a post URL in the Twitter Validator tool to validate it – it will show if your Twitter Cards are working properly.

Please, note that you should be logged in to use Twitter Validator.

That’s all there’s to it. Let me know if you have any questions.

Exit mobile version