Archive | Hacks

RSS feed for this section

Connect to a Second Database on WordPress and Display Results from It

Let’s suppose you need to connect to a second database on WordPress. The snippet bellow will do it. ?Download download1.txt1 2 3 <?php $secdb = new wpdb(‘secondusername’,’secondpassword’,’seconddatabasename’,’secondhost’); ?> Also you may check this snippet, which will allow you to display a simple result set from the second database. ?Download download2.txt1 2 3 4 5 6 […]

Enabling Login by Email on WordPress

Enabling login by email on WordPress is very easy. All you have to do is copy the snippet bellow and paste it on your functions.php ?Download download1.txt1 2 3 4 5 6 7 8 9 10 add_filter(‘authenticate’,’wpw_emaillogin’,20,3); function wpw_emaillogin($user,$username,$password){ if(is_email($username)){ $user = get_user_by_email($username); if ($user){ $username = $user->user_login; } } return wp_authenticate_username_password(null,$username,$password); }

GPLWT Reaches 20,000 Downloads And Offers New Amazing Features on the PRO version!

Inspired by the concepts “Scaling Up” and “Long Tail” by Chris Anderson and Henry Ford, GPLWT free celebrates 20,000 downloads and GPLWT PRO offers an advanced alternative for those users who want to make their posts lists better colored and formatted. GPLWT PRO has many cool features for you to build multiple lists of posts, using […]

Adding Categories and Tags on WordPress Pages

It’s pretty cool, useful and easy to add categories and tags on WordPress pages. Just put this code on your theme’s functions.php file: ?Download download1.txt1 2 3 4 5 6 <?php function wpw_pagecats() { register_taxonomy_for_object_type(‘post_tag’, ‘page’); register_taxonomy_for_object_type(‘category’, ‘page’); } add_action( ‘admin_init’, ‘wpw_pagecats’ );?> Later, you can retrieve the pages by category, on any template file, […]

Display All Images From a WordPress Post on a List(Separate Content Images and Text)

This function makes possible for you to display all images from a WordPress post on a list. Copy and paste the code bellow on your functions.php file. ?Download download1.txt1 2 3 4 5 6 7 8 9 10 11 12 function fnGetImgs($content){ preg_match_all(‘/<img[^>]+./’,$content,$imgarr); $totimgs = count($imgarr[0]); if ($totimgs > 0){ $resimgs = "<ul id=’imgspost’>"; for […]