Get back single-column dashboard in Latest WordPress

From WordPress 3.8 version came with new dashboard style. For Get back single-column dashboard in Latest WordPress, So you can use our code which can useful for every wordpress devloper.

Get back single-column dashboard in Latest WordPress

For getting back the single-column dashboard in WordPress 3.8, you need to add the following code in functions.php file.

// force one-column dashboard
function wpapi_single_screen_layout_columns($columns) {
$columns['dashboard'] = 1;
return $columns;
}
add_filter('screen_layout_columns', 'wpapi_single_screen_layout_columns');

function wpapi_single_screen_layout_dashboard() { return 1; }
add_filter('get_user_option_screen_layout_dashboard', 'wpapi_single_screen_layout_dashboard');
Get back single-column dashboard
Get back single-column dashboard

Add different Editor Styles for Custom Post Types in WordPress

There is custom post type support added from wordpress 2.9 in wordpress. Many times we create the different types of post type in wordpress and show it i different way. We use the different styles for showing the content types..

Add different Editor Styles for Custom Post Types in WordPress

Add different Editor Styles for Custom Post Types in WordPress
Add different Editor Styles for Custom Post Types in WordPress

In wordpress we have the visual and html editor. For adding the different styles for custom post types just open your functions.php file put the following code in that file.


function my_editor_style() {
 global $current_screen;
 switch ($current_screen->post_type) {
 case 'post':
 add_editor_style('editor-style-post.css');
 break;
 case 'page':
 add_editor_style('editor-style-page.css');
 break;
 case 'product':
 add_editor_style('editor-style-product.css');
 break;
case 'shop':
 add_editor_style('editor-style-shop.css');
 break;

}
}
add_action( 'admin_head', 'my_editor_style' );

If you are not wordpress developer then dont use above code. In purabtech.in site you will find many wordpress tutorials and tips and hacks and plugins. Please write to me on support@purabtech.in

Send email to site users about new wordpress posts

For increasing traffic of website. It is good to send email to users about new post. we have script for Send email to site users about new wordpress posts.

There are many wordpress plugins available for sending email but I given small code for sending email to wordpress users without using any wordpress plugins

Send email to site users about new wordpress posts
Send email to site users about new wordpress posts

If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file. Just copy and paste the following code on your functions.php file:

function send_email_users($post_ID)  {
    global $wpdb;
    $usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
    $users = implode(",", $usersarray);
    mail($users, "New Article is Published", 'A new article have been published on http://www.purabtech.in. Please visit');
    return $post_ID;
}
add_action('publish_post', 'send_email_users');

You just need to change my domain name to your domain name and put that in your functions.php file. If you are having any issues then Please write to me.
This wordpress hack, tip or trick written by wordpressapi.

Here is some very useful links for wordpress.

Check Following articles for great wordpress hacks of the all the time.

how to create contact us page without wordpress plugin
Add the extra new users details or fields to wordpress without plugin
Display wordpress Tags In A Dropdown Menu without plugin
How to change the Visual Editor Font Size wordpress without plugin
Display wordpress Tags In A Dropdown Menu without plugin
wordpress pagination style without wordpress plugin
show popular posts without wordpress plugin in theme
How to send smtp email through wordpress without plugin
How to put digg button in wordpress without plugin
Get the recent comments without using wordpress plugin or widget
How to Add the social Bookmar Icons in WordPress theme without wordpress plugins
How to exclude pages from wordpress menu without plugin
Show related posts with wordpress post without using any plugin

change Visual Editor Font Size without wordpress plugin

wordpress tutorial for, change Visual Editor Font Size without wordpress plugin. need to open your functions.php file and put following code in that file.

change Visual Editor Font Size without wordpress plugin

change Visual Editor Font Size without wordpress plugin
change Visual Editor Font Size without wordpress plugin

You need to open your functions.php file and put following code in that file.using following code you can change the font size of editor.

Note: If you are not having knowledge of wordpress code and php then dont use  the code.

add_action( ‘admin_print_styles-post.php’, ‘my_admin_css’ ); add_action( ‘admin_print_styles-post-new.php’, ‘my_admin_css’ ); function my_admin_css() { ?> <style type=”text/css”> #editorcontainer textarea#content { font-size: 2em !important } </style> <?php

 

disable html code in comments wordpress

WordPress tutorial for, disable html code in comments wordpress. We given code sample for functions file to prevent html code in wordpress comments section.

If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file. Just copy and paste the following code on your functions.php file:

disable html code in comments wordpress

function wordpress_comment_post( $incoming_comment ) {
	$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
	$incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] );
	return( $incoming_comment );
}

function wordpress_comment_display( $comment_to_display ) {
	$comment_to_display = str_replace( ''', "'", $comment_to_display );
	return $comment_to_display;
}
add_filter( 'preprocess_comment', 'wordpress_comment_post', '', 1);
add_filter( 'comment_text', 'wordpress_comment_display', '', 1);
add_filter( 'comment_text_rss', 'wordpress_comment_display', '', 1);
add_filter( 'comment_excerpt', 'wordpress_comment_display', '', 1);
disable html code in comments wordpress
disable html code in comments wordpress

add search form to wordpress navigation menu

In many wordpress premium theme search form added in navigation menu and many clients are demanding for same So here we created tutorial for adding search form.

WordPress tutorial for, add search form to wordpress navigation menu. If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file.

add search form to wordpress navigation menu

add search form to wordpress navigation menu
add search form to wordpress navigation menu

Using following code in you can add the search form in your menu bar.

function add_search_box($items, $args) {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
$items .= '
<ul>

<ul>
<ul>
	<li class="search-form">' . $searchform . '</li>
</ul>
</ul>

</ul>
';
return $items;
}
add_filter('wp_nav_menu_items','add_search_box', 10, 2);

There is very nice wordpress plugin which will add search box in navigation menu.

Search box on Navigation Menu

Search box on Navigation Menu
Search box on Navigation Menu

This plugin will add the default search box on main navigation menu that will save the space and flexibly fit with the menu.

adding custom styles to search widget in wordpress

Many people having issue when creating the wordpres theme and show search widget in theme. wordpress tutorial, adding custom styles to search widget in wordpress. In this tutorial we will show you how to show search widget with our custom styling.

adding custom styles to search widget in wordpress

you can override the default wordpress search widget.

adding custom styles to search widget in wordpress
adding custom styles to search widget in wordpress

For that use the following code.


function widget_override_search(){
?>
<ul>
	<li id="linkcat-2">
<h2> WordPress Search</h2>
<form id="searchform" style="padding: 10px;" action="<?php bloginfo('home'); ?>" method="get">
<div>
<input id="s" name="s" size="50" type="text" />
<input id="searchsubmit" type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
</div>

</form>
</li>
</ul>


<!--?php
}
if ( function_exists('register_sidebar_widget') )
 register_sidebar_widget(__('Search'), 'widget_override_search');

–>

how to disable wordpress post revisions

disable wordpress post revisions and increase wordpress performance. For improving the WordPress website or blog performance you need use following method.

WordPress saves the post revisions after every 2 min. That takes so much mysql storage.
To save MySQL storage, some WordPress user will be happy using this method, this method is Disable WordPress Post Revision.

how to disable wordpress post revisions

Why we need disabled this featured?

It’ because WordPress created such as dummy data revision and this one make our table sized increased. And if you have limited space, this is bad idea, and of course disable Post Revision also made your WordPress running faster.

Open your wp-config.php file and put the following code in that file. If you are not wordpress developer then dont use following code. Please consult with any wordpress developer for this code.

/* disable post-revisioning nonsense */
define('WP_POST_REVISIONS', FALSE);

wordpress pagination style without wordpress plugin

wp-pagenavi is most popular. wordpress pagination style without wordpress plugin, We need to install wp-pagenavi wordpress plugin for pagination styling.  When we think wordpress pagination style then first thing came in mind which is. We need to install wp-pagenavi wordpress plugin for pagination styling. There are multiple pagination plugins available for pagination styling but wp-pagenavi is most popular.

wordpress pagination style without wordpress plugin

I always recommend wordpress theme developers to not to use the wordpress plugins as much possible because any wordpress plugin will install the extra unuseful code also.

wordpress pagination style without wordpress plugin
wordpress pagination style without wordpress plugin

Here in this article I am giving you the example about wordpress pagination without using any wordpress plugin.

Just open your functions.php file and put following code.


function wpapi_pagination($pages = '', $range = 4)
{
 $showitems = ($range * 2)+1;

 global $paged;
 if(empty($paged)) $paged = 1;

 if($pages == '')
 {
 global $wp_query;
 $pages = $wp_query->max_num_pages;
 if(!$pages)
 {
 $pages = 1;
 }
 }

 if(1 != $pages)
 {
 echo "</pre>
<div class="\&quot;wpapi_pagination\&quot;">Page ".$paged." of ".$pages."";
 if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href="&quot;.get_pagenum_link(1).&quot;">« First</a>";
 if($paged > 1 && $showitems < $pages) echo "<a href="&quot;.get_pagenum_link($paged - 1).&quot;">‹ Previous</a>";

 for ($i=1; $i <= $pages; $i++)
 {
 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
 {
 echo ($paged == $i)? "<span class="\&quot;current\&quot;">".$i."</span>":"<a class="\&quot;inactive\&quot;" href="&quot;.get_pagenum_link($i).&quot;">".$i."</a>";
 }
 }

 if ($paged < $pages && $showitems < $pages) echo "<a href="\&quot;&quot;.get_pagenum_link($paged">Next ›</a>";
 if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href="&quot;.get_pagenum_link($pages).&quot;">Last »</a>";
 echo "</div>
<pre>\n";
 }
}

Above function will give the wordpress pagination style like google search engine.

Then open style.css file from your wordpress theme file and put following code in that file.


.wpapi_pagination {
clear:both;
padding:20px 0;
position:relative;
font-size:11px;
line-height:13px;
}

.wpapi_pagination span, .wpapi_pagination a {
display:block;
float:left;
margin: 2px 2px 2px 0;
padding:6px 9px 5px 9px;
text-decoration:none;
width:auto;
color:#fff;
background: #555;
}

.wpapi_pagination a:hover{
color:#fff;
background: #3279BB;
}

.wpapi_pagination .current{
padding:6px 9px 5px 9px;
background: #3279BB;
color:#fff;
}

Then finally where you want to show the wordpress pagination there in area put following code (index.php, etc..)


if (function_exists("wpapi_pagination")) {
 wpapi_pagination($additional_loop->max_num_pages);

 

wordpress pagination style without wordpress plugin
wordpress pagination style without wordpress plugin

If you are having any issues or question about adding the wordpress pagination without plugin then please write me.

 

 

convert plain text URI to HTML links in wordpress themes

When you put some URL and email address you need to manually add the link URL to that text. This action always takes the some time of wordpress blogger. WordPress has facility to add the links to your URL and email address automatically.

 

convert plain text URI to HTML links in wordpress

This facility is available in wordpress since wordpress 2.7 version but many wordpress theme and plugin developers never used this functionality.

WordPress provides the make_clickable() function for convert plain text URI to HTML links. This function able to convert URI, www, ftp, and email addresses. Finishes by fixing links within links. You just need to pass the string parameter to this method.

More detail information you can find in following file.
wp-includes/formatting.php.

You can use this method in your functions.php file also. Use the following code.

add_filter('the_content', 'make_clickable');

By using this code you are able to covert the URI, www, ftp, and email addresses in to link.

If you are having any issues or question about make_clickable method then please write to me.