Menu bar

Wednesday 31 December 2014

Redirect user after successfull registration to a required wordpress page.

REDIRECT USER ON REGISTRATION.

Have you ever wanted to redirect users to a specific wordpress page or another website page after they register to your WordPress site?

Recently i have worked on project where

user must be redirected to particular wordpress page.

Some are interested in thanking people after they register or just send them to a specific wordpress  page for newly registered members.

one can easily do tisk task with a small snippet, putting in functions.php file.

Here you have to use 'registration_redirect' filter.

code:

function redirect_user(){    return home_url( '/pagename/' );}add_filter( 'registration_redirect', 'redirect_user' );


you can return a static url instead of home_url() of any other website.

This task can be done easily through plugin " Peter’s Login Redirect "

Through plugin you can redirect user from login and even from registration page to a page were you want user to be.

Sunday 28 December 2014

How to remove the width and height from img tag in wordpress posts and pages?


REMOVE WIDTH AND HEIGHT ATTRIBUTES.

It would be great for the images to be able to scale proportionally within their parent container in wordpress to make perfect responsive. This effect can be take place if you remove the width and height attributes from img tag in wordpress.


In order to remove width and height , here we use filter hooks.There are two hooks we will used here. one is post_thumbnail_html and other is image_send_to_editor
 

We will replace width and height attribute with NULL i.e. blank space using preg_replace() function of php.

place this code in functions.php file.
add_filter( 'post_thumbnail_html', 'remove_wps_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_wps_width_attribute', 10 );
 function remove_wps_width_attribute( $html ) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html;
}

Friday 26 December 2014

Remove HTML unwanted comment tags from comment section.

REMOVE HTML COMMENT TAGS

By default WordPress includes basic HTML tags in the post comment form in order to allow commentators to use it for formatting there comments.

As you can see in the  image, comment form is listing some HTML tags in the below section.


But, many times it is not necessary to show these HTML tags in the form.

Moreover, with design perspective, displaying these tags doesn’t look good in the comment forms. So you can either remove or hide it from the comment form.

You can perform that task easily by CSS.
i.e. Display none that block.

Place this code in function.php file of your theme.

<?phpadd_action('init', 'unwantedtags');function unwantedtags() {global $allowedtags;// remove unwanted tags$unwanted = array('abbr','acronym','blockquote','cite','code','del','strike','strong','b','em','q');foreach ( $unwanted as $tag )unset( $allowedtags[$tag] );}?>


Corner Ribbon Using CSS



CORNER RIBBON



HTML SOURCE


<div class="wrapper"> <div class="ribbon-wrapper-green"><div class="ribbon-green">NEWS</div></div> </div>

CSS SOURCE

.wrapper { margin: 50px auto; width: 280px; height: 370px; background: white; border-radius: 10px; -webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3); -moz-box-shadow: 0px 0px 8px rgba(0,0,0,0.3); box-shadow: 0px 0px 8px rgba(0,0,0,0.3); position: relative; z-index: 90; } .ribbon-wrapper-green { width: 85px; height: 88px; overflow: hidden; position: absolute; top: -3px; right: -3px; } .ribbon-green { font: bold 15px Sans-Serif; color: #333; text-align: center; text-shadow: rgba(255,255,255,0.5) 0px 1px 0px; -webkit-transform: rotate(45deg); -moz-transform: rotate(45deg); -ms-transform: rotate(45deg); -o-transform: rotate(45deg); position: relative; padding: 7px 0; left: -5px; top: 15px; width: 120px; background-color: #BFDC7A; background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45)); background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45); background-image: -moz-linear-gradient(top, #BFDC7A, #8EBF45); background-image: -ms-linear-gradient(top, #BFDC7A, #8EBF45); background-image: -o-linear-gradient(top, #BFDC7A, #8EBF45); color: #6a6340; -webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3); -moz-box-shadow: 0px 0px 3px rgba(0,0,0,0.3); box-shadow: 0px 0px 3px rgba(0,0,0,0.3); } .ribbon-green:before, .ribbon-green:after { content: ""; border-top: 3px solid #6e8900; border-left: 3px solid transparent; border-right: 3px solid transparent; position:absolute; bottom: -3px; } .ribbon-green:before { left: 0; } .ribbon-green:after { right: 0; }


Monday 22 December 2014

How to show or hide specific widget on specific page?


SHOW OR HIDE SPECIFIC WIDGETS ON SPECIFIC PAGES

Did you ever think to show or hide your WordPress widgets on selective pages...of course you can thought of.Because there are some wordpress widgets that should be display on certain pages to make websites look better then before.

You can do this task by putting this snippet in your function files....

Here you have to change the widgetname to name of the widget to show or hide and you can get that name by inspecting your code..

Change the pagename to the name of page on which the widget to be show or hide and this is the slug name of your page...

//Show widget on particular page..
add_filter( 'widget_display_callback', 'show_hide_widget', 10, 3 );
function show_hide_widget( $instance, $widget, $args ) {
  if ( $widget->id_base == 'widgetname' ) { 
     if ( !is_page( 'pagename' ) ) {
         return false;
     }
  }
}

//Hide widget on particular page..
add_filter( 'widget_display_callback', 'show_hide_widget', 10, 3 );
function show_hide_widget( $instance, $widget, $args ) {
  if ( $widget->id_base == 'widgetname' ) { 
     if ( is_page( 'pagename' ) ) {
         return false;
     }
  }
}

Even there is a plugin used to perform this task and the name of the plugin is "Display Widgets".

Saturday 1 November 2014

Turn on WordPress Error Reporting


How to turn on error reporting for testing your website?


Sets error reporting to true in wordpress  indicates which PHP errors are reported

Comment out the top line there, and add the rest to your wp-config.php file to get more detailed error reporting from your WordPress site. Definitely don't do this live, do it for local development and testing.

// define('WP_DEBUG', false); define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); @ini_set('display_errors', 0);
This changes will be done in wp-config.php
This will log all errors notices and warnings to a file called debug.log in wp-content (if Apache does not have write permission, you may need to create  the file first and set the appropriate permissions (i.e. use 666) )