Skip to content

Instantly share code, notes, and snippets.

@wcodex
wcodex / genesisFeaturedImage
Created April 26, 2014 05:11
Display featured imges in Genesis post
add_action( 'genesis_before_post_content', 'wcodex_before_post_content_image', 5 );
function wcodex_before_post_content_image() {
if ( is_page() ) return;
if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
@wcodex
wcodex / displayFeaturedImage
Created April 10, 2014 05:23
Display featured images before post content
add_action( 'genesis_before_post_content', 'wcodex_before_post_content_image', 5 );
function wcodex_before_post_content_image() {
if ( is_page() ) return;
if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
@wcodex
wcodex / mageLatestProducts
Created April 10, 2014 05:18
Get the latest product collection in Magento
$allproduct = Mage::getModel(‘catalog/product’)->getCollection()->setOrder(‘entity_id’,'desc’)->getData();
$_helper = $this->helper(‘catalog/output’);
foreach($allproduct as $product){
echo ‘<div class="product_box">’;
$obj = Mage::getModel(‘catalog/product’);
$productid = $product['entity_id'];
$_product = $obj->load($productid); // Enter your Product Id in $product_id
$productName = $_product->getName();
$productDescription = $_product->getDescription();
@wcodex
wcodex / magentobasics
Created April 10, 2014 05:08
Get basic details of Magento store
//To Get the current store
$store = Mage::app()->getStore();
//To get Store Id
$store_id = Mage::app()->getStore()->getStoreId();
//To get Store Code
$store_code = Mage::app()->getStore()->getCode();
//To get Website Id
@wcodex
wcodex / imagesclass
Created April 8, 2014 15:57
Image classes in Bootstrap 3.0
//for Rounded responsive
<img src="lion.jpg" class="img-rounded img-responsive" alt="" />
//for circle responsive
<img src="lion.jpg" class="img-circle img-responsive" alt="" />
For poloroid responsive
<img src="lion.jpg" class="img-poloroid img-responsive" alt="" />
@wcodex
wcodex / gist:10146673
Created April 8, 2014 15:52
Grid layout in Bootstrap 3.0
<div class=”col-md-6″>Sample text goes here/half part</div>
<div class=”col-md-6″>Sample text goes here/half part</div>
@wcodex
wcodex / gist:8825693
Created February 5, 2014 15:12
Custom WordPress search form using bootstrap 3.0
?>
<form class="navbar-form" role="search" action="<?php echo site_url('/'); ?>" method="get" >
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="s" id="search" value="<?php the_search_query(); ?>">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
@wcodex
wcodex / gist:8715048
Created January 30, 2014 18:13
Implement or create slider using Twitter Bootstrap
<div class="container">
<h1>Carousel in web page using Bootstrap</h1>
<div class="carousel" id="sample-carousel">
<div class="carousel-inner">
<div class="item active"><img alt="" src="http://lorempixel.com/1200/600" />
<div class="caurosel-caption">
<h4>How are you?</h4>
This is my sample carousel using Bootstrap</div>
</div>
<div class="item"><img alt="" src="http://lorempixel.com/1200/600/car" /></div>
@wcodex
wcodex / gist:6823571
Created October 4, 2013 09:50
How to display the category Name in catalog/product/list.phtml
<?php
/*This code is used to display the caterogy name in list.phtml file*/
echo $this->getLayer()->getCurrentCategory()->getName()
/*How to hide or delete the page title on same list.phtml
1. go to catalog/categoy/page.phtml
2. Comment out or delete follwing code
*/
<div class="page-title">
<h1><?php echo $this->getTitle() ?></h1>
</div>
@wcodex
wcodex / gist:6820676
Created October 4, 2013 03:43
Add stylesheet in WordPress in correct way
<?php
/*
You can add the stylesheet link tag directly on the page using the wp_head action
You can add the stylesheet link tag directly to the page anywhere.
You can use the wp_enqueue_scripts action to add a handle to the wp_enqueue_style.
Syntax
wp_enqueue_style( $handle, $src, $deps, $ver, $media );