Skip to content

Instantly share code, notes, and snippets.

//In function.php
// For Rewriting the URLS in WORDPRESS
add_filter('query_vars', 'add_state_var', 0, 1);
function add_state_var($vars){
$vars[] = 'cp';
return $vars;
}
add_filter('query_vars', 'add_singled_var', 0, 1);
function add_singled_var($vars){
$vars[] = 'dcat';
@iamayaz
iamayaz / child_categories.php
Last active May 19, 2016 05:51
Getting wordpress child categories data by parent category
// To getting the parent category by slug
$digital_post_cat = get_category_by_slug( 'digital-post' );
$digital_post_args = array(
'type' => 'post',
'child_of' => $digital_post_cat->term_id,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => FALSE,
'hierarchical' => 1,
'taxonomy' => 'category',
@iamayaz
iamayaz / powfunctions
Last active February 7, 2016 12:45
Custom pow() function in php
function raiseToPower($base,$exponent)
{
// multiply the base to itself exponent number of times
$result=1;
for($i=1;$i<=$exponent;$i++)
{
$result = $result * $base;
}
return $result;
}