Select Page
How to add Facebook Comments to WordPress without a plugin

How to add Facebook Comments to WordPress without a plugin

Instaling Facebook Comments to replace your standard wordpress comment system can drive more engagement and shareability to your blog articles.

I will explain below, how to add Facebook Comments to WordPress without a plugin, in 3 easy steps.

Here are some reasons why you might want to do that:

  1. Less additional code – With more and more plugins on your wordpress instalation you are adding more unnecessary code that may slow down your website. Less plugins you have the better, especially if you already have lots of plugins installed.
  2. It is more secure – Every time you add a plugin, you might open up to malware injections and hackers will exploit every security hole, espepcialy if the plugin is not up-to-date, and this can cause alot of problems for you. If you don’t trust the author, do not install that plugin. Research first if the plugin is trusted by others, of it has a good support community etc. NOT ALL PLUGINS ARE CERATED EQUAL.
  3. Fast and easy installation – The thing is that manualy setting up facebook comments is easier then you think and all it takes is a couple on minutes. See the proccess below.

 

STEP 1: The Setup of Facebook Comments

Go ahead to the official Facebook Comment developer page and setup your own settings. Type the path to your blog page ex: https://mywebsite.com/blog, insert the desired width (% – for responsive full width, px – for specific width), number of desired post, and hit “Get Code” to generate the code.

Your code will look like this

1
2
3
4
5
6
7
8
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.10";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Inside your WordPress Dashbord go to Appearance> Editor and look for the file header.php and right below the < body > tag, insert the generated facebook code.

For Divi and Extra Theme users: Go to Divi>Theme Options> look for the Integrations tab, Enable Body Code if you didn’t do that already and insert the code on the right of “Add code to the < body >”.

You can also achive this with FTP if you know your way around.

Note! – You should use a child theme.

STEP 2: Installing the Facebook Comment Code

Place the code below (or the oneyou got generated from facebook) where you want the comments to appear (usualy at the end of your posts). This code utilizes dynamic functions to make Facebook Comments unique for each page. You should look for single.php file to edit inside your theme/child theme folder.

1
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-width="100%" data-numposts="5" data-mobile="Auto-detect" data-colorscheme="light" data-order-by="time"></div>

Here is an example where i’ve put the code for this blog

How to addFacebook Comments to WordPress without a plugin

To see the full list of display options and tags, visit the Facebook Comments settings.

STEP 3: Testing your setup

So you’ve got to this part of the tutorial. You’ve placed the two code in the right places, and now is time to check if your implementation works. Now you can visit a few of your blog posts to verify if everything is functioning and shows properly.

That is it!

Feel free to leave a comment and share with your friends.

How to Redirect all HTTP requests to HTTPS with htaccess

How to Redirect all HTTP requests to HTTPS with htaccess

Access your website via FTP or via your server’s File Manager and search at the root of your WordPress instalation for the .htaccess file. Here you have 3 solutions to solve the same question:

How to redirect all HTTP request to HTTPS.

Before you edit the .htaccess file, I recommend to make a backup to be able to revert your changes (in case something goes wrong).

So here you go, copy and paste the code below in your .htaccess file, save it, and re-upload it.

Solution 1

1
2
3
RewriteEngine On<br />
RewriteCond %{HTTPS} off<br />
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

These lines of code will direct all HTTP requests to https://www.example.com as well as redirect https://example.com to https://www.example.com.

Solution 2

1
2
3
4
5
RewriteEngine On<br />
RewriteCond %{HTTPS} off<br />
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]<br />
RewriteCond %{http_host} ^example.com [NC]<br />
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

Solution 3

1
2
3
4
5
6
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]<br />
RewriteCond %{HTTP_HOST} ^www.domain.com$ [OR]<br />
RewriteCond %{HTTPS_HOST} ^domain.com$<br />
RewriteRule ^(.*)$ "https\:\/\/www\.domain\.com\/$1" [R=301,L]

Leave a comment with what worked for you. Go ahead and share if you have a different aproach.

How to display category description only on the first category page

How to display category description only on the first category page

If you have multiple categories that are paged on your blog, you may want to show the Category Description only on the first category page.

You may wonder how can I achive this.

It’s not that hard to do it as long as you follow the steps I provide.

  1. Connect to your FTP account and search inside your theme folder for the file archive.php. If it’s a premium theme, you should have one in you main theme folder or mabe other subfolder.
  2. Once you’ve identified the file, go ahead and download (to have a backup copy might be a good idea) and then open it up for editing.
  3. Now you’ve got to identify something similar to the code below and replace it with this one.
1
2
3
4
5
6
7
8
9
10
&lt;?php
if (is_category()) {
  $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
  if ($page == 1) {
    echo category_description();
//you don't need to include the category id on the actual
// category page - wordpress figures it out.
  }
}
?&gt;

And that’s it, pretty simple eh?

If you found this helpful please leave a comment and subscribe to my newsletter for all my latest content.

What to do if your website is not working with www prefix

What to do if your website is not working with www prefix

I got a new server and a new website and now my website is not working with www prefix, but is accessible without www prefix.

The solution of this problem it has a easy fix, but it involves 2 different actions:

  1. Adding a DNS Record
  2. Redirecting a www to non-www (as this was my goal)

After I had installed a new website on a newsite.domain.com subdomain it worked perfectly, but when i type the www prefix i get “the webpage is not available” kind of error.

To put things in perspective, I use a Digital Ocean Droplet with ISPConfig 3 Server on a Debian Jessie OS. But this can work on a wide range of configurations.

Here is how I fixed this:

First step go to Digital Ocean website and sign in: 

  1. Login to Digital Ocean Account  account
  2. Go to NetworkingDomains> select yourdomain.com
  3. Add a new A Record like this: www.newsite in “Enter Name” field and your droplet IP in “Host” filed like you see below.  
  4. Hit Create A Record button and you`re done!

Remember to change with YOUR IP address of your sever.

I asume  that you already have the non www record added, if you don`t do the same thing without the www in front of your newsite subdomain like you can see below.

Note! If you have a cPannel you can add that record in your cPannel dashboard, DNS section

Second step – go to your ISPConfig dashboard and login

  1. Go to Sites> select your site  (subdomain in my case) and click on it
  2. Then open the Redirect tab
  3. At Redirect Type select R=301,L
  4. From SEO Redirect select www.domain.tld => domain.tld

This is it!

Do you have a better solution? I`ll be happy to hear about it!

How to change your ISPConfig admin password

How to change your ISPConfig admin password

When you manage more then one ISPConfig server or multiple websites, it just happens sometimes to forget the passwords (in case you didn`t write them down) or can`t find the file where you put them.

Don`t worry! There is a simple way to reset your ISPConfig admin password .

To change your ISPConfig admin password: Get your mysql password first!

/usr/local/ispconfig/server/lib/mysql_clientdb.conf.

I use putty to login to my console. You can also do this in virtual console from your droplet.

So, let`s go!

  • In the terminal type the commands below, in the right order as shown:
    • mysql -u root -p
  • select your database
    • use dbispconfig;
  • And insert the next query
    • UPDATE sys_user SET passwort = md5(‘parola_noua’) WHERE username = ‘admin’;

(Replace your “new_password” with one that you desire.)

After this you can login again with your user and new password through server interface.

This is all that you have to do!