How to Modify get_comment_author_link to Open Comment Authors Website on new Window

wordpress-logo-notext-rgbBy default, get_comment_author_link  redirects the user to the site which was entered by comment author when they wrote comment in same window of our site. What if we want this to open on new window?

Add following code to functions.php in your live theme directory

//Display website on new window when readers click Commenter's name 
add_filter( "get_comment_author_link", "pxzoom_modifiy_comment_author_anchor" );
function pxzoom_modifiy_comment_author_anchor( $author_link ){
    return str_replace( "<a", "<a target='_blank'", $author_link );
}

WordPress: Conditional tag to check a specific menu

wordpress-logo-notext-rgb
Following conditional tag usually use in this filter function, wp_nav_menu_items

if( $args->theme_location == 'primary' )

 

if( $args->theme_location == 'secondary' )

 

if( $args->theme_location == 'primary' )

For an example, I want to add search box to Primary Menu in WPZOOM theme name Videozoom. Conditional tag above make sure the search only show in a specif menu (Primary)
1. Open functions.php
2. Add following code to functions

add_filter('wp_nav_menu_items','search_box_function', 10, 2);
function search_box_function( $nav, $args ) {
if( $args-&gt;theme_location == 'primary' )
return $nav."<li class='menu-header-search'><form role='search' action='".get_bloginfo('url')."' id='searchform' method='get'><input id="s" type="text" name="s" placeholder="Search" /><input id="searchsubmit" type="submit" value="Search" />";

return $nav;
}

How to add widgetized and custom sidebars on WordPress theme

WordPress themes are usually come with Widgetized sidebars where you can drag and drop widgets. It’s okay when we don’t need more widgetized sidebars to the theme, but we probably think to add more when we think widgetized sidebar solution to your customization problem, for instance you want to add a banner ad to header area or footer area. This requires coding solution in few themes and each theme could have different solution.
This plugin, Custom Sidebar provides easy solution. The installation is straightforward, we can download from wordpress.org,  upload it to wp-content/plugins directory and activate the plugin in the plugin menu panel or Add New and search Custom Sidebar from the plugin menu panel

Now, we want to add new widgetized sidebar (or in this case widgetized area).  I want to show a Banner Ad with Text Widget dragged and dropped to the new widgetized sidebar/area.

1. Create new sidebar in the Custom Sidebar panel, type name and description and click Create Sidebar. I make a sidebar name Footer: Banner Ad

CS New Sidebar
2. Go to Widgets panel, see that the newly created sidebar name Footer: Banner Ad  is at the bottom of Sidebars
3. Drag and drop text widget to the Footer: Banner Ad sidebar, copy and paste your banner ad code

CS: Text Widget
4. Add following code to a theme file, e.g footer.php.

<?php if (function_exists('dynamic_sidebar')) { dynamic_sidebar('Footer: Banner Ad'); } ?> 

WordPress Conditional Tag for Login Page

wordpress-logo-notext-rgb
WordPress have conditional tags. The Conditional Tags can be used in your Template files to change what content is displayed and how that content is displayed on a particular page depending on what conditions that page matches

Following conditional tag is specific to Login Page, that is currently not available on WordPress Codex

if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) {
//Conditional statement here
}

Full Screen Background on WP Login Page

WordPress - the logo

The following function add full screen background on WP Login page

1. Open functions.php in your theme directory

2. Add this function to functions.php


// LOGIN - full background
function my_login_style() {
?>
<style type="text/css">
 body.login {
 background:url('http://yourwebsiteaddress.com/wp-content/uploads/wploginbg.jpg') no-repeat center center fixed;
 -webkit-background-size: cover;
 -moz-background-size: cover;
 -o-background-size: cover;
 background-size: cover;
 position:fixed;
 top:0;
 left:0;
 z-index:10;
 overflow: hidden;
 width: 100%;
 height:100%;
 }

</style>
<?php
}
add_action('login_head', 'my_login_style');
?>

3. Save