jQuery(document).ready(function () {
var st = 0;
var ed = 0;
var cnt = 10;
var tAg = '.companyinfo div.result-body';
hideShow(0, cnt, '', tAg);
jQuery('.nextData').click(function () {
st = parseInt(st + cnt);
ed = parseInt(st + cnt);
//alert(ed);
jQuery(tAg).hide();
jQuery('.prevData').show();
hideShow(st, ed, cnt, tAg);
});
jQuery('.prevData').click(function () {
st = st - cnt;
ed = ed - cnt;
//alert(ed);
jQuery('.nextData').show();
jQuery(tAg).hide();
hideShow(st, ed, cnt, tAg);
});
/* Pagination End */
function hideShow(st, ed, rcrds, tAg) {
jQuery(tAg).hide();
if (st >= 10)
{
jQuery('.prevData').show();
} else
{
jQuery('.prevData').hide();
}
//Count Number of Div
var len = jQuery(tAg).size();
if (len - st <= rcrds || len < ed) {
jQuery('.nextData').hide();
}
//alert(st + 'p' + ed);
jQuery(tAg).slice(st, ed).each(function () {
jQuery(this).show();
});
}
});
/* * * Pagination End * */
Sunday, 11 October 2015
Simple Pagination With jQuery
Enable PHP in Widget Without Plugin - WordPress
/* * ****************** add php support ****************** */
add_filter('widget_text', 'enable_php_code', 99);
function enable_php_code($text) {
if (strpos($text, '<' . '?') !== false) {
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
}
return $text;
}
Custom Breadcrumb in WordPress
/** Breadcrumb Code * */
function the_breadcrumb()
{
if (!is_front_page())
{
echo '';
echo 'Home';
echo " ";
if (is_single())
{
strip_tags(the_title());
} elseif (is_page())
{
strip_tags(the_title());
} elseif (is_category() && !is_tax())
{
echo strip_tags(single_cat_title());
} elseif (is_archive() && is_tax())
{
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
echo $term->name;
} elseif (is_404())
{
echo '404-Page Not Found';
}
echo '';
}
}
Function For Calling WordPress Menu
function callMenu($id)
{
$args = array(
'menu' => $id,
'container' => 'div',
'container_class' => 'common',
'container_id' => '',
'menu_class' => 'menu',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'items_wrap' => '%3$s
',
'depth' => 0,
'walker' => ''
);
wp_nav_menu($args);
}
Function For Cart Icon Woo-Commerce
function getCartIcon(){
global $woocommerce;
// get cart quantity
$qty = $woocommerce->cart->get_cart_contents_count();
// get cart total
$total = $woocommerce->cart->get_cart_total();
// get cart url
$cart_url = $woocommerce->cart->get_cart_url();
// if multiple products in cart
if($qty>1)
echo 'Cart'.$qty.' products | '.$total.'';
// if single product in cart
if($qty==1)
echo 'Cart1 product | '.$total.'';
}
Subscribe to:
Posts (Atom)