how to hide wordpress login page error messages

wordpress tutorial, how to hide wordpress login page error messages. Here in this article We are Hiding wordpress dashboard login error is very basic thing for keep away hackers.

how to hide wordpress login page error messages
how to hide wordpress login page error messages

Hiding wordpress dashboard login error is very basic thing for keep away hackers. Whenever you and any hackcer are trying to login using the correct username but with the wrong password, that will give you a message saying “Error: Incorrect Password.” hacker will got the clue that the username entered is in the system, and that they simply need to crack its password. Same with username also you will got following message.
“Error: Invalid username”
For avoiding this thing you just need to open your functions.php file and put the following code in that file

add_filter('login_errors', create_function('$a', "return null;"));

This hack will remove the WordPress error by displaying nothing when a login is incorrect.

 

How to add custom text in every wordpress post

wordpress tutorial, How to add custom text in every wordpress post. There is always common content we want put in every post. using following function we can add the custom text in every wordpress post.

How to add custom text in every wordpress post

just open your functions.php file from wordpress theme folder and put the following code in that file.


function mytext($content)
{
return "The addtional content goes here: ".$content;
}
add_filter('the_content', 'mytext');

How to add custom text in every wordpress post
How to add custom text in every wordpress post

wordpress get posts with custom field value

wordpress tutorial, wordpress get posts with custom field value. Many people use the custom meta fields in wordpress posts. Here given code snippet for same.  In this article I will show you how to retrieve the custom field from wordpress post. For fetching the custom fields you just need to use the following code.

wordpress get posts with custom field value

$key_values = get_post_meta($post->ID, 'key');
custom meta tags
wordpress get posts with custom field value

If you are using normal post or custom post type above function will work. Here is another code for fetching the custom post type meta values.

$loop = new WP_Query( array( 'post_type' => 'product', 'posts_per_page' => 10 ) );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
the_content();
global $post;
$custom = get_post_custom($post->ID);
echo $thumbnail_url = $custom["thumbnail_url"][0];
echo $product_info = $custom["product_info"][0];
echo '
<div>';
the_content();
echo '</div>
';
endwhile;

how to make an email address clickable in wordpress

wordpress tutorial, how to make an email address linkable in wordpress. Here we given very simple and short code which you can add in theme.

When ever we insert the URL , email  in post we need to put the link manually. WordPress provided the way to automatically make the URL and Email clickable in wordpress post.

how to make an email address clickable in wordpress

how to make an email address clickable in wordpress

You just need to add following code in your wordpress theme’s functions.php file.

add_filter('the_content', 'make_clickable');

For more help you can check following URL:
http://codex.wordpress.org/Function_Reference/make_clickable

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.

most popular posts wordpress without plugin

Many times you want to show the popular posts in your wordpress theme and you use popular post wordpress plugin or widget for showing the popular posts in your wordpress theme. As much possible you need to avoid the wordpress plugins for minimal code.

most popular posts wordpress without plugin

With very easy steps you can fetch the most popular posts from your wordpress. Most common trick or technique is on comments base you can fetch the popular posts.

You just need to open your functions.php file from wordpress posts and put following code in file.


// Get Most Popular Posts in theme
function popular_posts_by_comments( $posts = 5) {
 $popular = new WP_Query('orderby=comment_count&posts_per_page='.$posts);
 while ($popular->have_posts()) : $popular->the_post();
?>
<li>
<div>
 <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
 <span><?php comments_popup_link('0 Comment', '1 Comment', '% Comments', 'comments-link', ''); ?></span>
 </div> <!--end .info-->
 <div></div>
</li>
<?php endwhile;
}

This is very easy code to fetch you wordpress popular posts. Here I am fetching only 5 popular posts from wordpress. You can fetch the multiple popular posts by changing the $post variable value.

In wordpress theme sidebar or footer section if you want to show the popular post then just use following code.

popular_posts_by_comments();

most popular posts wordpress without plugin
most popular posts wordpress without plugin

where you want to show the popular posts.

show popular posts without wordpress plugin in theme
show popular posts without wordpress plugin in theme

Remove Unwanted Meta Boxes from wordpress dashboard through wordpress theme

When we login to wordpress admin area that time we first saw the admin dashboard. Many tabs and section are not useful in admin dashboard section for wordpress admin and sometimes we don’t know what is that sections.

Remove Unwanted Meta Boxes from wordpress dashboard through wordpress theme

We saw the right now, recent comments, quick press, stat, recent drafts, incoming links, wordpress development blog, other wordpress news, plugins and more sections in wordpress dashboard section. Most of that section are not useful to wordpress admin. So is that better to remove unwanted section from dashboard.

Remove Unwanted Meta Boxes from wordpress dashboard through wordpress theme
Remove Unwanted Meta Boxes from wordpress dashboard through wordpress theme

For disable the dashboard section we are going to use the wp_dashboard_setup method. In wordpress dashboard there are multiple meta boxes listed. some of them as follows:

//Main column
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']

//Side Column
$wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']
$wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']

For removing the widgets or meta boxes from dashboard you need to open your functions.php file from wordpress theme folder and put following code in that file.

function remove_dashboard_meta_boxes(){
  global$wp_meta_boxes;
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
  unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
  unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}

add_action('wp_dashboard_setup', 'remove_dashboard_meta_boxes')

This code will remove the incoming link, right now, plugins, recent comments and secondary section from wordpress dashboard section.

Remove Unwanted Meta Boxes from wordpress dashboard through wordpress theme
Remove Unwanted Meta Boxes from wordpress dashboard through wordpress theme

If you want the more information about wordpress dashboard widget then check following URL
http://codex.wordpress.org/Dashboard_Widgets_API

If you are having any issue or questions about wordpress dashboard then please write to me.

Create multiple widgets in wordpress theme

WordPress tutorial for, In this article we will show, how to Create multiple widgets in wordpress theme. Widgets for very important in wordpress themes and plugins. First I need to tell you this widget api is located in following file.

wp-includes/widgets.php

For enable the sidebar support in wordpress theme you need to register atleast one sidebar in wordpress api. For enabling the side bar you need to just open the functions.php file and put following code in that file.

if ( function_exists('register_sidebar') )
register_sidebar();

This is enable the global sidebar for your wordpress theme.

If you want multiple sidebar in your wordpress theme then use the following code. I created two sidebars in my wordpress theme. First is normal sidebar and second is footer sidebar.

For main sidebar showing just open your sidebar.php file put following code in that file.


if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Main Sidebar') ) :
 endif;

For showing second widget in footer section open your footer.php file and put following code in that file.


if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer Sidebar') ) :
 endif;

Then go to your widget section through admin panel and select your widget which you want to show in widget sections.

Create multiple widgets in wordpress theme
Create multiple widgets in wordpress theme

If you are having any issues or question about using widget in wordpress theme then write to me.

how to use shortcodes in wordpress posts

Short code api is introduced in wordpress from 2.5 version. Since short code is very popular and used by wordpress plugin developers. Many wordpress theme and plugin developers do use the shortcode api regularly.

how to use shortcodes in wordpress posts

how to use shortcodes in wordpress posts
how to use shortcodes in wordpress posts

Using shortcode api is very easy. If you want to use the shortcode in your wordpress theme then open your functions.php file and put following code. Here is example for using shortcode.


function wordpressapi_content() {

echo "Hello World";

}

add_shortcode('wordpressapi_content', 'wordpressapi_content');

Create any page and just put following line in that post or page.

[wordpressapi_content]

If you put following code in your page or post then you can see the hello world content in your page or post.

If you want to add the google adsence using shortoce then use the following code.


function google_adsence($atts) {
 return ' "<script type="quot;text/javascript"quot;">"<!--
google_ad_client = "quot;ca-pub-4949877136251097"quot;;
/* 160x600, created 4/7/08 */
google_ad_slot = "quot;5503695728"quot;;
google_ad_width = 160;
google_ad_height = 600;
//--">
"</script">
"<script type="quot;text/javascript"quot;
src="quot;http://pagead2.googlesyndication.com/pagead/show_ads.js"quot;">
"</script">
'
}

add_shortcode('google_adsence', 'google_adsence');

Then just put the following words in your post or page or widget section.

[google_adsence]

Your adsence will be displayed. For advanced information about shortcode you should check following URL

http://svn.automattic.com/wordpress-tests/wp-testcase/test_shortcode.php

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