Add a security credit for wordpress site

Hiee friends, I found  a code over wordpress site which was checking footer page for its credit and dies if not matching with the phrase. function wp_initialize_the_theme_load() { if (!function_exists(“wp_initialize_the_theme”)) { wp_initialize_the_theme_message(); die; } } function wp_initialize_the_theme_finish() { $uri = strtolower($_SERVER[“REQUEST_URI”]); if(is_admin() || substr_count($uri, “wp-admin”) > 0 || substr_count($uri, “wp-login”) > 0 ) { /* …

wordpress: display custom post type of a category by making a function

wordpress: display custom post type of a category by making a function so that you can call this function on a template and show related post type only. I am also using a limit so it will be easy to get the variable in quantity. Here ‘masonry-portfolio-categories’ is a taxonomy and ‘masonry-portfolio’ is a post …

Defer iframe for your website to make your website loading fast

Defer iframe for your website to make your website loading fast. iframe source loading took some time and which blocks other scripts to load  as quickly as you can. We can defer the iframe so the other scripts can load quickly and our iframe will be loading after page scripts is fully loaded. This method …

Create a custom widget for your wordpress site

Create a custom widget for your wordpress site. // Creating the widget class wpb_widget extends WP_Widget { function __construct() { parent::__construct( // Base ID of your widget ‘wpb_widget’, // Widget name will appear in UI __(‘My first Widget’, ‘wpb_widget_domain’), // Widget description array( ‘description’ => __( ‘Sample widget for beginner’, ‘wpb_widget_domain’ ), ) ); } …

Create a custom post type and its metaboxes

In WordPress everything is a post_type and anything you would like to attach with this post_type is possible by metaboxes. Posts are stored in the wp_post table and its meta information is stored in wp_postmeta table. This is a very basic structure which WordPress follows and every new collection is build around it. posts and …

Add WordPress pagination with a custom function

1. Here is the pagination Code. Put it directly to the function.php at the theme directory. function pagination($pages = ”, $range = 4) { $showitems = ($range * 2)+1; global $paged; if(empty($paged)) $paged = 1; if($pages == ”) { global $wp_query; $pages = $wp_query->max_num_pages; if(!$pages) { $pages = 1; } } if(1 != $pages) { …

Create your own shortcode in wordpress

Its very easy to Create your own shortcode in wordpress. Simply follow this code and copy from here to your wordpress function.php placed at the theme directory. This will create shortocde [wp_get_childpages] that is attached with a function  wp_get_list_child_pages() function wp_get_list_child_pages() { global $post; if ( is_page() && $post->post_parent ) $childpages = wp_list_pages( ‘sort_column=menu_order&title_li=&child_of=’ . …

XML to PHP array convert

function xml2array1($url, $get_attributes = 1, $priority = ‘tag’) { $contents = “”; if (!function_exists(‘xml_parser_create’)) { return array (); } $parser = xml_parser_create(”); if (!($fp = @ fopen($url, ‘rb’))) { return array (); } while (!feof($fp)) { $contents .= fread($fp, 8192); } fclose($fp); xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, “UTF-8”); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, trim($contents), $xml_values); xml_parser_free($parser); …

Validate gravity form from unwanted text

Validate gravity form for unwanted words use the below code and put it at your functions.php function bld_strpos_arr($haystack, $needle) { if(!is_array($needle)) { $needle = array($needle); } foreach($needle as $what) { $pos = stripos($haystack, $what); if( $pos !== false) { return true; } } return false; } /* * Our bad words validation function */ add_filter(‘gform_validation’, …