Create herder & footer pages and include in Drupal 7

  1. You will create two files header.php and footer.php.
  2. Create a folder “include” in your theme directory.
  3. Suppose that your theme directory is “aviweb” sites/all/themes/aviweb. Put header.php and footer.php file in “sites/all/themes/aviweb/include” theme folder.
  4. By using html and php you can write code in header.php and footer.php.
  5. Now you can include both files in page.tpl.php in header area and footer area like PHP.

<?php include_once($theme_path.’/include/header.php’); ?>

<?php include_once($theme_path.’/include/footer.php’); ?>


Hot to update Drupal 7 website

  1. Make a backup of your Drupal instance (database).
  2. Set your site on maintenance mode.(Click here)
  3. Delete all the files & folders inside your original Drupal instance except for /sites and its sub-folders.
  4. Warning: If your Drupal installation is built from a distribution your site will break if you delete the /profiles folder. Don’t delete the profile folder that corresponds to the distribution you installed, for example /profiles/kickstart if you installed Drupal Commerce Kickstart.
  5. Copy all the folders and files except /sites from inside the extracted Drupal package [tar ball or zip package] into your original Drupal instance location.
  6. Some updates do not include changes to setting.php and some do. If the update release includes changes to settings.php you will need to replace your old settings.php in …/sites/default/ with the new one, and then edit the site-specific entries (eg database name, user, and password) in the setting file.
  7. If you have modified files such as .htaccess or robots.txt re-apply those changes to the new files.
  8. If you have a favicon.ico file that was deleted replace it too
  9. Login to your site as administrator
  10. Run “update.php” by navigating to http://yourdrupalsitename/update.php and follow the process to update your Drupal instance
  11. Disable maintenance mode.

Create font page template in Drupal 7

To create front page template please find below steps

  • Create “page–front.tpl.php” template in current theme and copy the home page PHP code into that.
  • Next create one “Home” page and Promote as front page like below screenshot.

  • Once we done above steps it will work as front page with “page–front.tpl.php” code.

Custom post type list with pagination in while loop


$loop = new WP_Query(array(‘post_type’ => ‘custom_post’,  ‘posts_per_page’ => 5,  ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1 ));


<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

<?php the_title(); ?> <?php the_content(); ?>

<?php endwhile; ?>

<?php  $uniqnum = 999999999;

echo paginate_links( array( ‘base’ => str_replace( $uniqnum, ‘%#%’, get_pagenum_link( $uniqnum ) ),

‘format’ => ‘?paged=%#%’,

‘current’ => max( 1, get_query_var(‘paged’) ),

‘total’ => $loop->max_num_pages ) );


Restrict specific products in Woo-Commerce shop

Put below code in functions.php

add_action( ‘woocommerce_product_query’, ‘aviweb_product_query’ );add_action( ‘woocommerce_product_query’, ‘aviweb_product_query’ );
function aviweb_product_query( $q_array ){

$product_ids_on_sale = array(); $product_ids_on_sale[] = 7076;

$q_array->set( ‘post__not_in’, $product_ids_on_sale );


post__in -> products within array

post__not_in -> products not in array