Wordpress

This code will track product purchase / checkout. Copy and paste below codes to your functions.php and don’t forget to change xxxxxxxxxx with your own facebook pixel code.

 

Read More Embed facebook conversion pixel for woocommerce

Here is code I usually use to find ancestor or parent of a category [php] function getCategoryAncestor($cat,$index=0){ $parentCatList = get_category_parents($cat,false,’,’); $parentCatListArray = @split(",",$parentCatList); $topParentName = $parentCatListArray[$index]; $charReplace = array(" " => "-", "(" => "", ")" => ""); $topParentSlug = strtolower(strtr($topParentName,$charReplace)); $catAncestor[‘ancestor’] = $topParentName; $catAncestor[‘ancestor_slug’] = $topParentSlug; return $catAncestor; } // How to use :…

Read More WordPress : How to get category ancestor

There are two types of hook in WordPress, filter and action. And in this occasion I will try to give examples about Actions hook. According to codex.wordpress.org: Actions: Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more…

Read More WordPress : Custom Action Hook in Action

I know we have get_permalink() in WordPress to get permalink by id of specific page. So this post is only alternative how to get the permalink by name, slug or title. 1. Get Page ID by name, slug or title [php] <?php function rh_get_page_id($name) { global $wpdb; // get page id using custom query $page_id…

Read More WordPress : Get page permalink by name, slug or title outside loop