How To Change Facebook Link Thumbnail and Description

To change the Facebook link thumbnail and description in WordPress we need to utilise a coding technology called “OpenGraph”. This allows a website to tell Facebook what information to display when someone shares a link.

Facebook for Developers has a tool known as Debugger that allows a user to see what a Facebook link will look like when copied and pasted into a post. You can enter any link here to see what title, thumbnail and description Facebook will use for that link.

Here is the code to place in your functions.php file in order to change the links, description, title and thumbnail. Make sure you replace the relevant sections with your own data for your site. Setting the third parameter for the add_action ensures the function is executed first and the code is inserted at the top of the heading so it takes preference over any other OpenGraph tags in the page.

The above code will show the same description and image for all pages. If you want a different description or image for a specific page on your site then you can use the following code which checks for a specific page name. In this instance it’s for my contact page.

Leave a Reply

Your email address will not be published. Required fields are marked *