Skip to main content

Posts

Showing posts with the label wordpress hack

Add new avatars to your wordpress and Say Good-Bye to Mystery Man

If you are like most of the other wordpress developers out there, then you might also had this problem with the default mystery man in wordpress. You also would wanted to change the deafualt avatar of your comments with something nice. It's not that hard. It's infact very easy. Just add this to your functions.php file within your theme folder. /** * add a default-gravatar to options */ if ( !function_exists('fb_addgravatar') ) { function fb_addgravatar( $avatar_defaults ) { $myavatar = get_bloginfo('template_directory') . '/images/avatar.gif'; $avatar_defaults[$myavatar] = 'people'; $myavatar2 = get_bloginfo('template_directory') . '/images/myavatar.png'; $avatar_defaults[$myavatar2] = 'wpengineer.com'; return $avatar_defaults; } add_filter( 'avatar_defaults', 'fb_addgravatar' ); } Why this? When you can have this! Happy coding! For any queries or suggestions give a comment below!

Add categories & tags to post programatically

There often time when you want to add categories or tags to a post from code. Wordpress codex has a good deal of resource on this but most of the time it's hard for the beginners to grasp. In this post we will try to crack this the easiest way. First let us create an array of categories id. Then we simply have to use the wp_set_object() function, which by default take 3 parameters: The post id. Array of categories to add to the post. taxonomy type (category in this example). $category_ids = array(4, 5, 6); wp_set_object_terms( $post_id, $category_ids, 'category'); Here is how tags can be added: Adding tags to a post is extremely easy as well. The only difference with the code to add categories is the taxonomy "post_tag" instead of "category". Related Posts: Inserting Posts Programatically to WordPress Insert Custom Content After Each Post

Change the WordPress Login page logo link without plugin.

Are you making a site for your client and frustrated with the login page logo linking to the WordPress site? Well you are not the only one. But there is a very easy way to change this behavior without any plugin. All you have to do is add the following line to your functions.php file within your theme folder. add_filter("login_headerurl","the_url"); function the_url($url) { return get_bloginfo('siteurl');//return the current wp blog url } This will link the logo to your own wordpress blog. If you don't know how to change the default WordPress logo with one of your logo, then follow this post that wonderfully illustrates the same. More On The Topic: The official wordpress documentation on this can be found here . If you have any queries please use the comment form below.

Customizing the wordpress login page without Plugin

Every one love to see their site totally branded. It does feel good when your users see the WordPress login page when they have to login, may be just to post a comment. Biggest problem come when you are developing for a client. Well though most of them don't know the solution is simple. You don't have to rely on any plugin just to do few modifications on the login page. You just have to add few lines to your functions.php file within your theme folder. "This is the final result, after adding the below code to functions.php" add_action("login_head", "my_login_head"); function my_login_head() { echo "<style>body.login #login h1 a { background: url('".get_bloginfo('template_url')."/styles/logo.gif') no-repeat scroll center top transparent; height: 49px;width: 229px; margin-left:auto;margin-right:auto; } body {background: url('".get_bloginfo('template_url')."/styles/bg.jpg') re...

Using Featured Image in WordPress

Today there are innumerable blogs on any topic you would choose. If you are a blogger your main priority would be to make your blog, stand out! Make it more attractive and tempt people to read what you right. One of the most important technique that major blogs use is setting a featured image for each post. This can be achieved very easily as it 's there in-built in wordpress. But you have to enable it in functions.php file within your theme folder. Here is how you do that: add_theme_support( 'post-thumbnails' ); Paste this within your functions.php file. Additionally you can specify which should have this feature in an array like this: // Add it for posts add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for pages add_theme_support( 'post-thumbnails', array( 'page' ) ); You also additional control over this, you explicitly decide the dimension or hard crop the thumbnails etc. The dimension can be set like this: //the scale ...