WordPress get user id by login name
If you have ever wondered how to get the user id from user login name in wordpress, here is the answer. By using get_userdatabylogin $user = get_userdatabylogin(’loginname’); if($user){ echo $user->ID; }
Dynamic WordPress URL
If you have more than one domains (addon domains) for the same wordpress site you can add the following to your wp-config.php to override the default WP_HOME and WP_SITEURL definitions with dynamic host address. Adding these two definitions also reduces the number of database queries and thus improves site performance. Here is an example (note [...]
Changing the site url in WordPress
If you move your wordpress installation to a new location (a new domain or another folder), you need to change all urls within your wp database. You might find some plugins to do this task but in my opinion the easiest way to do this is by using phpMyAdmin. Just run the following SQL Statements [...]
Allow iframe in WordPress Posts
If you’ve ever tried adding an iframe to your WordPress post, and then switched the TinyMCE editor to Visual mode, you’ve found that the editor strips out your iframe code. This can be annoying. Just add this snippet to the functions.php file in your theme folder to prevent TinyMCE from killing your iframe. function [...]
Launch Fancybox automatically
Fancybox currently does not directly support a way to automatically launch. The work around I was able to get working is creating a hidden anchor tag and triggering it’s onclick event. Make sure your call to trigger the onclick event is included after the jquery and fancybox js files are included. The code I used [...]
Decode HTML entities with jQuery
Decoding HTML entities can be so easy with jQuery. The following code snippet converts all HTML entities to their applicable characters:
Absolute and relative URLs
The URI general syntax allows a resource to be specified as an absoluteor a relative URL. Absolute URLs identify the protocol http://, the host, and the path of the resource, and can be used alone to locate a resource.
Googleon and Googleoff Tags
There are several ways to instruct Google to stay away from various pages in your site: Robots.txt directives Nofollow attributes on links Meta noindex/nofollow directives X-Robots noindex/nofollow directives ..and so on. These directives all function in different ways, but they all serve the same basic purpose: control how Google crawls the various pages on your [...]
Test your Website with webpagetest.org
When it comes to optimazing your web page performance, www.webpagetest.org is a very helpful tool to test your webpage and find out how to improve its performance. Through “Webpage Test” you can set a number of parameters before you begin testing a URL. The test results are comprehensively broken down into speed tests, JavaScript file [...]