How to add Follow us on Google News button in your WordPress website?
To add a “Follow us on Google News” icon on your WordPress website, follow these steps:
- Get Your Google News Publisher URL:
- First, you need to have your Google News publisher URL.
- Goto https://publishercenter.google.com
- Open Publication > Edit > Review & Publish
- Under Testing your publication get your follow url
- This is the URL that directs users to your publication on Google News. It usually looks something like:
https://news.google.com/publications/CAIiE...
- Prepare the Icon:
- First, you’ll need an icon that represents “Google News Follow us Button”. You can either design one, purchase one, or find a free one online. Make sure you have the right to use the icon on your website.
- Download SVG of Follow us on Google News [Full Resolution]
- Download SVG of Follow us on Google News [150 px]
- Download PNG of Follow us on Google News
- Upload the Icon to Your WordPress Media Library:
- Go to your WordPress dashboard.
- Navigate to
Media
>Add New
. - Upload the “Follow us on Google News” icon.
- If you are using SVG file – please upload it via FTP to any directory
- Once uploaded, click on the icon and copy the
File URL
from the right-hand side. This will be the URL you’ll use in the code.
- Add the Code to Your Theme’s
functions.php
File:
- From your WordPress dashboard, go to
Appearance
>Theme Editor
. - On the right side, find and click on the
functions.php
file to edit it. - Add the following code to the end of the
functions.php
file:
function add_google_news_icon($content) {
$icon_url = 'PASTE_YOUR_ICON_URL_HERE'; // Replace with the URL you copied
$google_news_url = 'YOUR_GOOGLE_NEWS_URL_HERE'; // Replace with your Google News URL
// Append the icon with hyperlink to the content
$content .= '<a href="' . $google_news_url . '" target="_blank" rel="noopener noreferrer"><img src="' . $icon_url . '" alt="Follow us on Google News" style="margin-top:20px;" /></a>';
return $content;
}
add_filter('the_content', 'add_google_news_icon');
- Replace
PASTE_YOUR_ICON_URL_HERE
with the URL you copied from the Media Library. - Replace
YOUR_GOOGLE_NEWS_URL_HERE
with the URL of your Google News page. - The
target="_blank"
attribute ensures the link opens in a new tab. - The
rel="noopener noreferrer"
attribute is a security measure when usingtarget="_blank
.
- Save Changes:
- Click the
Update File
button to save your changes.
Now, when you view a post on your website, you should see the “Follow us on Google News” icon at the end of the content. When clicked, it will open your Google News page in a new tab.