JetPack related posts plugin stopped displaying related post results few months back when I shifted the servers to DigitalOcean VPS and started using nginx as web server instead of Apache. Together with JetPack Sharing plugin not working and related posts not displaying, I started searching logs to find what is wrong? but I didn’t find any errors or warning in the logs and my website on nginx was working perfectly without any errors.
So I started playing around and whenever I clicked on the sharing plugins button I used to be redirected to the same post page instead of going to the desired social networking site.
As you can see in the above image that, the page is just reloaded instead of redirecting to the Twitter website for Tweeting about that page.
After digging around for some time, I saw that the arguments are not passing through. so I once again went to WordPress website to search for nginx related setup instructions and found out that in the nginx configuration file there is no $args
attribute for passing the arguments. Below is the code found in my nginx configuration file :
try_files $uri $uri/ /index.php;
Instead of the above line it should be :
try_files $uri $uri/ /index.php?$args;
Fixing Related posts and Sharing plugin
To fix JetPack not working plugins edit the configuration file by following the below steps :
- Open nginx configuration file for your WordPress installation in your favorite text editor . for me it is vim
vim /etc/nginx/sites-enabled/best2know
where
best2know
is the name of the configuration file. - Find the below line in the file (it should be near the top) :
try_files $uri $uri/ /index.php;
- press i to edit text if you are using
vim
, to change the above code to the one below :try_files $uri $uri/ /index.php?$args;
- After that to save the file press esc and type :wq.
- Now that the file is saved just restart nginx by using the below command:
service nginx restart
Now JetPack related posts and sharing plugin should be functioning properly. Because JetPack related posts are requested by adding ?relatedposts
argument at the end of the Post URL. Which in turns returns related posts Data in JSON format.
Here’s an Video tutorial for those, who are unable to understand or are getting confused on how to proceed? to fix Jetpacks problem with NGINX