How to add js and css in wordpress?

 * Proper way to enqueue scripts and styles
function theme_name_scripts() {
	wp_enqueue_style( 'style-name', get_stylesheet_uri() );
	wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );

add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

Display special priced products on your Magento homepage

Step 1: Open your homepage CMS page and click on the content tab. Paste the following:

{{block type="catalog/product" name="" alias="product" template="catalog/product/special.phtml"}}


Step 2: First of all this is the code were that we’re going to be using to do this.

Mage::getSingleton('core/session', array('name' => 'frontend'));
$_productCollection = Mage::getResourceModel('catalogsearch/advanced_collection')


$todayDate = date('m/d/y');
$tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
$tomorrowDate = date('m/d/y', $tomorrow);

$_productCollection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('special_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $tomorrowDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left');
<div class="specials_block">
<div class="page-title"><h2><?php echo $this->__('Specials') ?></h2></div>
<?php  $_collectionSize = $_productCollection->count();  ?>

<ul class="products-grid-new row">

<?php  $i=0; foreach($_productCollection as $_product): ?>
<?php $i++; if($i!=5){?>
<li class="item span3<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><span></span><?php echo $this->htmlEscape($_product->getName()) ?></a></h3>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image non-mobile-img"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(270, 217) ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></a>
<div class="block_holder">

<span class="price">
<?php echo $this->getPriceHtml($_product, true, '-new') ?></span>

<div class="descr"><?php echo $_product->getShortDescription() ?></div>
<div class="actions">
<a href="<?php echo $this->helper('checkout/cart')->getAddUrl($_product) ?> " class="icon-shopping-cart"></a>
<a href="<?php echo $_product->getProductUrl() ?>" class="icon-info-sign"></a>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<a href="<?php  echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="icon-star-empty"></a>
<?php endif; ?>
<?php $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ?>
<a href="<?php echo $_compareUrl ?>" class="icon-retweet"></a>

<?php } else {break;}?>
<?php endforeach ?>

You can then paste this into a file and name it specials.phtml and save it into your frontend template folder catalog/product.

How to install/setup language pack in Magento

Are you confused with installing language pack in Magento? Don’t be its too easy 😉

In this post we will go through

Installing language pack in Magento

Step 1 : Select the language you want to set on your website. Download the desired language pack from this link Language Packs

Step 2 : Put the language pack folder in app/locale. Suppose we are installing a spanish language pack so the name of the folder would be es_ES.

Step 3 : Create a new store view for your language. Suppose for spain Goto System->Manage Stores->Create Store View. Add the name, code, status and priority of your store.

Step 4 : Configure your language with your store view. Goto System->Configuration->General->General. Follow the steps as below screenshot.

Select the newly created store.

Select relevant Locale and save it. For our case its spain so i have selected spain.

Step 5 : Thats it. Now goto frontend and enjoy your multi lingual website. Though to display the flag as shown in the screenshot you need to do little programming. I’ll try to cover it in future.


In Next tutorial i’ll post how to do custom inline translations for backend and frontend in Magento. Please leave your comments and suggestion below.

Create Custom Post Type with Texamony(Categories) in WordPress

Custom Post types are very handy tool in wordpress. To create a custom Post Type is pretty easy.

Goto functions.php file of your theme folder and copy the below code. You will get the new section for adding posts. These can be used for many stuffs like creating a small plugin for News, FAQ’s etc.

Below is the code to be added in functions.php. I have added the comment wherever required.


Continue reading

Display magento products by category ID

$categoryIds = array(18);//category id

$collection = Mage::getModel('catalog/product')
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
->addAttributeToFilter('category_id', array('in' => $categoryIds))
$_collectionSize = $collection->count()

Get detail of products

<?php $i=0; foreach ($collection as $_product):  ?>
<?php $i++;?>
<?php if($i!=4){ // for maximum 3 product ?>
<div class="product-image">

<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(); ?>" />


<div class="product-name">

<a href="<?php echo $_product->getProductUrl();?>"><?php echo $_product->getName(); ?></a>


<div class="product-price">

<?php echo Mage::helper('core')->currency($_product->getPrice(),true,false);?>


<div class="product-Short Description">

<?php echo    Mage::helper('core/string')->truncate($product->getShortDescription(), $length = 50, $etc = '...', $remainder = '', $breakWords = true); // word limit for short description ?>


<?php } else{break;}?>
<?php endforeach ?>


how to display article intro image in joomla module?

Article display by yourtheme/html/com_content/article/tmpl/default.php file.

you can use module mod_articles_latest so edit mod_articles_latest/tmpl/default.php file.

* @package Joomla.Site
* @subpackage mod_articles_latest
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt

defined('_JEXEC') or die;
<ul class="latestnews<?php echo $moduleclass_sfx; ?>">
<?php foreach ($list as $item) : ?>
<a href="<?php echo $item->link; ?>">
<?php echo $item->title; ?></a>
<img src="<?php echo json_decode($item->images)->image_intro; ?>"/> //new line
<?php endforeach; ?>