Restrict categories in wp drop down categories function

The function wp_dropdown_categories is used to display all categories as a drop down.

If a site uses different custom post types and if we want to show only categories used by a particular custom post type, we can use the following code. The following code displays categories used by the post type ‘highlight’.

$exclusive_post_type = 'highlights';
$exclude_cats = array();
$nonemptycats = get_terms( 'category' );
foreach( $nonemptycats as $term ){
$term_id = $term->term_id;
$term_objects = get_objects_in_term( $term_id, 'category' );
$exclude_term = true;

foreach( $term_objects as $post_id ){
if ( $exclusive_post_type === get_post_type( $post_id ) ){
$exclude_term = false;

if ( $exclude_term ) $exclude_cats[] = $term_id;
$args = array(
'show_option_none' => 'All categories',
'orderby' => 'name',
'hide_empty' => 1,
'exclude' => $exclude_cats,
'hierarchical' => 1,
'hide_if_empty' => true
wp_dropdown_categories( $args );

AWS Giving different users access to different websites on same server

Suppose if you have an EC2 instance where you host 2 sites, say website1 and website2.

Files of website1 are in the folder /var/ww/html/website1
Files of website2 are in the folder /var/ww/html/website2

Say you want to give access to website1 for some developers and to website2 for another set of developers.

So let us have 2 groups, say group1 and group2.

To create groups we need to run

groupadd group1
groupadd group2

Then we add an user to group1

useradd -G group1 developer1

passwd developer1

Now login as developer1 using the sudo and su commands.
sudo su developer1

Now go to developer1’s home directory.
cd /home/developer1

Generate a new public/private key pair for this user using the ssh-keygen command.

ssh-keygen -b 1024 -f developer1 -t dsa

Now create the .ssh/.authorized_keys file with the appropriate ownership and permissions.

mkdir .ssh
chmod 700 .ssh
cat > .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
chown developer1:group1 .ssh
chown developer1:group1 .ssh/authorized_keys

Now download the private key using winscp or any other sftp program. Convert the file to .ppk file (Filezila will automatically convert if you try to add the key)

chown developer1:group1 /var/www/html/website1

Now the developers in group1 has write access only to /var/www/html/website1 but they have read access to all other directories.

Linux commands

gpasswd -d user group – Removes user from the group

zip -9 -r zipfile foldername – To zip a folder

service httpd restart – Restart Apache

mysqldump -h hostname -u username -p –databases databasename > datebase.sql – Export the database to the file database.sql

mysql -h hostname -u username -p databasename < database.sql - Import database wget - to download a zip file to the folder unzip zipfilename - to unzip a zipped file

dsIDXpress not functioning properly in Thesis 2

dsIDXpress is a plugin for wordpress that gives IDX functionality to wordpress based site.

It allows visitors to search and browse available properties in your MLS.

Search engine will index properties from MLS on the website.

dsIDXpress works with Thesis 1.x series, but recently did a site on Thesis 2. Widgets, shortcodes etc will work without any issues.

But the page that displays the details of single property is not working. It just shows the contents of home page.

dsIDXpress is not recognizing any templates in Thesis 2.

Hope the plugin developer and thesis theme developer share their knowledge and figure out a fix / solution.

WordPress Plugin to change Display name as first name and capital letter of second name

Please update!';
if (version_compare($wp_version,"2.5","<")) { exit ($exit_msg); } function sd_new_login_filter ($login) { /* Don't do anything to login, just see if already in database.*/ global $wpdb, $sd_is_new_login; $id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$login'");
$sd_is_new_login = (isset($id)) ? false : true;
return $login;

function sd_substitute_displayname_filter ($display_name) {
global $sd_is_new_login;

if ($sd_is_new_login){
$first_letter = substr($_POST['last_name'], 0, 1);
$display_name = $_POST['first_name']." ".$first_letter;
return $display_name;
add_filter('pre_user_login', 'sd_new_login_filter');
add_filter('pre_user_display_name', 'sd_substitute_displayname_filter');
add_action ('admin_head','make_display_name_f_name_last_name');
function make_display_name_f_name_last_name(){

$users = get_users(array('fields'=>'all'));

foreach($users as $user){
$user = get_userdata($user->ID);
$firstletter = substr($user->last_name, 0, 1);
$display_name = $user->first_name . " " . $firstletter;

if($display_name!=' ') wp_update_user( array ('ID' => $user->ID, 'display_name' => $display_name) );
else wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );

if($user->display_name == '')
wp_update_user( array ('ID' => $user->ID, 'display_name' => $user->display_login) );


Done with the help of following threads:

Redirect to another domain using web.config file

<?xml version=”1.0″ encoding=”UTF-8″?>





<rule name=”Redirect to”>
<match url=”(.*)” />
<add input=”{SERVER_PORT}” pattern=”443″ negate=”true” />
<action type=”Redirect” url=”{R:1}” />




The notes I am writing here help me (perhaps others as well) to remember the solutions I figured out for the Wordpress / PHP issues that I have come across …