Check if a page template is active – WordPress

Add the below given code in to your functions.php

global $wpdb;

$templateQry = “select meta_key from $wpdb->postmeta where meta_key like ‘_wp_page_template’ and meta_value like ‘Template1′”;
$result = $wpdb->query($templateQry);
if ($result) {
echo “page Template1 is active”
} else {
echo “page Template1 is not active”
}

Password protection – htaccess

Create .htaccess file and paste the below given code into it .

AuthName “Member’s Area Name”
AuthUserFile /path/to/password/file/.htpasswd // Dont for got give a valid path of .htpasswd file
AuthType Basic
require valid-user

Create .htpasswd and gienterve the user name and encrypted password separated with ‘:’. The text would look like as follows

username:encryptedpassword
phpcodez:60h5w63DqQfls

NOTE : You can create the password using the link “http://www.4webhelp.net/us/password.php”