YPSA Webmaster's Blog

Skip to content Skip to sidebar
  • Change “From” name of email in WordPress when it sends notifications to users

    This snip of code lets you customize the email “from” that appear on emails sent from WordPress. By default the “From Name” on emails sent from wordpress has a name “WordPress”.  To change from name with your blog name, simply copy and paste the code into the function.php file of your theme.

    
    // change mail from name
    function reset_fromname($email){
     $wpfrom = get_option('blogname');
     return $wpfrom;
    }
    
    add_filter('wp_mail_from_name', 'reset_fromname');
    
    

    You can also change From email address. To do this, insert code below into functions.php

    
    // change  from email address
    function reset_fromemail($email){
     $wpfromemail = 'example@yourdomain.com';
     return $wpfromemail;
    }
    
    add_filter('wp_mail_from', 'reset_fromemail');
    
    
  • How to add post attachment image as featured image if no thumbnail is assigned or set a default fallback image in WordPress.

    Set post attachment as featured image

    Featured image is assigned with post for various purposes in wordpress. If themes are designed to show mini thumbnail images next to recent posts, related posts, popular posts etc. you must assign featured image from the post editor panel unless no thumbnail will be shown. Featured images also give professional touch to content and create good impression to the readers.

    Sometimes  users forget to assign featured image while publishing their posts. Fallback of post thumbnail may breakdown the theme layout.  If you are a theme designer, you should set a default fallback image to prevent breakdown of layout and design. There is another possible way to set a featured image automatically if any image is found as attachment  with post.

    Now I am going to show three options, first one is setting a default fallback image if no post thumbnail assigned, second option is automatically set featured image if post has any uploaded image attachment and third option is if no post thumbnail, no attachment found then display a default fallback image.

    Continue reading…

  • How to create CSS3 drop shadow around div elements

    CSS BOX Example

    Creating drop shadows on elements is always done with images, but it is possible to create drop shadows on elements using CSS.

    The css box-shadow property allows designers to easily implement drop shadow effect on box elements.

    I am going to show some examples how to write code in css to create drop shadow with box-shadow property.

    Syntax

    box-shadow: horizontal-shadow vertical-shadow blur spread color Continue reading…

  • How to add your profile picture next to all comments in all blog posts using Gravatar

    Featured image

    When you read and comment on blogs, you see there are some default icons (commonly on a gray background a white guy) and some profile pictures are shown next to the commenter’s name. This is called Avatar. Commenter doesn’t need to upload any profile picture on each blog. Blog owners do not allow uploading picture for the unregistered users.  Question is how this is possible to show profile photo with comments as a guest user or simple visitor?

    Yes, it is possible because of Gravatar. Gravatar.com is an awesome neat website that allows you to host an avatar and use it all over the web.

    Gravatar is linked to the email address. Retrieve the avatar for a user who provided a user ID or email address. Most commonly used in the comments section.

    Your Gravatar is an image that follows you from site to site appearing beside your name when you do things like comment or post on a blog. Avatars help identify your posts on blogs and web forums.

    Continue reading…

  • Remove unnecessary meta information from your WordPress site

    Removing unnecessary meta information enhance security and performance of your wordpress site.

    Many WordPress themes by default include the version information. It helps hackers to easily target your site. You should not display which version of WordPress that’s running on your site to the general public.

    You can cleanup unnecessary meta information putting some code in your theme functions.php

    
    <?php
    //remove unnecessary meta information
    remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
    remove_action( 'wp_head', 'index_rel_link' ); // index link
    remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
    remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
    remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
    remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version
    
    ?>
    
    
  • Stop unwanted tagging on Facebook

    Unwanted Tagging on Facebook

    Getting tagged in pictures in which you appear is fun, but when your friends start tagging you in totally unrelated pictures, it just gets annoying. Tagging on Facebook has become a tradition. People just post any pic and tag friends in it. They need to understand that this is a lame attempt to get likes, and it is very annoying. What can you do if you ar

    e tagged in an unrelated pic? Here are some simple solutions:

    1) If you are tagged in an image, you can simply visit it and remove the tag. Just open the pic and click on Report/Remove tag.

    2) You can set an option that will allow you to review the tags from friends, and allow only the ones that you like. This way your friends can tag you, but the tag won’t appear unless you approve it. Look at the top right corner and you’ll see your name there along with some other options. Click on the downward arrow and select privacy settings. Scroll down to the option that says ‘Timeline and tagging’. Click on ‘Edit settings’. You’ll see that the option that says ‘Review posts friends tag you in before they appear on your timeline’. Click on its option (it will be marked off by default). Enable this option and now you won’t be tagged in unwanted posts.

  • How to add custom avatar icon in WordPress

    To add custom avatar image in wordpress, pest this code into theme functions.php

    <?php
    /* Add a Custom Default Gravatar */
    
    add_filter( 'avatar_defaults', 'new_avatar' );
    function new_avatar($avatar_defaults){
    $new_avatar = get_stylesheet_directory_uri() . '/images/avater_icon.jpg';
    $avatar_defaults[$new_avatar] = "Theme Default Icon";
    return $avatar_defaults;
    }
    ?>
    

    Continue reading…

  • How to create custom meta description for each individual posts in wordpress

    In respect to search engine optimization, we may need to add unique meta description for each post so that search engines can show the predefined custom excerpt in their search results . We can do it creating a custom meta box for the posts.

    We will write functions for appearing a text box below the post editor section where we will put our individual meta description. We will use post excerpt (first 150 characters) if the field is left blank. Continue reading…