15 Hacks to Pimp Your WordPress Website

Despite the general awesomeness of WordPress plugins there is a common situation when plugins are an unnecessary headache for the web masters. The point is any plugin brings a series of updates that can crash your WordPress website functionality in some cases.

So if you have some basic PHP skills (we mean really really basic – like being able to copy and paste the pieces of code) or web development experience you might be interested in making some little changes to your WordPress website with your own hands. With this in mind we have prepared for you some short and interesting WordPress hacks that would improve your WP-based without involving any third-party software. There are many simple functions that actually don’t need being plugin-powered. These are pagination, contact forms, social media buttons etc. Anyways, just know that this post isn’t meant to criticize the existence and usage of WordPress plugins – it’s just an alternate point of view so you could have choice. This post is meant for those seeking souls that are looking for simple and interesting solutions to improve their WordPress themes functionality.

How to build a WordPress Post Pagination without plugin

wordpress-theme-hacks

* * *

Display Your Popular Posts In WordPress Without A Plugin

wordpress-theme-hacks

* * *

How to Add Live Comment Preview to Comment Text area without Plugin

wordpress-theme-hacks

* * *

Show Number of Retweets in WordPress Without a Plugin

wordpress-theme-hacks

* * *

Breadcrumbs without plugin

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!--?php 
function the_breadcrumb() {
		echo '
<ul id="crumbs"-->';
	if (!is_home()) {
		echo '
<ul>
	<li><a href="';
		echo get_option('home');
		echo '">';
		echo 'Home';
		echo "</a></li>
</ul>
";
		if (is_category() || is_single()) {
			echo '
<ul>
	<li>';
			the_category('</li>
	<li> ');
			if (is_single()) {
				echo "</li>
	<li>";
				the_title();
				echo '</li>
</ul>
';
			}
		} elseif (is_page()) {
			echo '
<ul>
	<li>';
			echo the_title();
			echo '</li>
</ul>
';
		}
	}
	elseif (is_tag()) {single_tag_title();}
	elseif (is_day()) {echo"
<ul>
	<li>Archive for "; the_time('F jS, Y'); echo'</li>
</ul>
';}
	elseif (is_month()) {echo"
<ul>
	<li>Archive for "; the_time('F, Y'); echo'</li>
</ul>
';}
	elseif (is_year()) {echo"
<ul>
	<li>Archive for "; the_time('Y'); echo'</li>
</ul>
';}
	elseif (is_author()) {echo"
<ul>
	<li>Author Archive"; echo'</li>
</ul>
';}
	elseif (isset($_GET['paged']) &amp;&amp; !empty($_GET['paged'])) {echo "
<ul>
	<li>Blog Archives"; echo'</li>
</ul>
';}
	elseif (is_search()) {echo"
<ul>
	<li>Search Results"; echo'</li>
</ul>
';}
	echo '';
}
?&gt;

* * *

Show Top Commentators In WordPress Without A Plugin

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function top_comment_authors($amount = 5){
 
	global $wpdb;
 
	$results = $wpdb-&gt;get_results('
		SELECT
			COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url
		FROM
			'.$wpdb-&gt;comments.'
		WHERE
			comment_author_email != "" AND comment_type = "" AND comment_approved = 1
		GROUP BY
			comment_author_email
		ORDER BY
			comments_count DESC, comment_author ASC
		LIMIT '.$amount
 
	);
 
	$output = "
    “; foreach($results as $result){ $output .= ”

  • “.$result->comment_author.”
  • “; } $output .= “

1
2
3
4
5
";
 
	echo $output;
 
}

* * *

Restrict Admin Menu Items Based on Username

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function remove_menus()
{
    global $menu;
    global $current_user;
    get_currentuserinfo();
 
    if($current_user-&gt;user_login == 'username')
    {
        $restricted = array(__('Posts'),
                            __('Media'),
                            __('Links'),
                            __('Pages'),
                            __('Comments'),
                            __('Appearance'),
                            __('Plugins'),
                            __('Users'),
                            __('Tools'),
                            __('Settings')
        );
        end ($menu);
        while (prev($menu)){
            $value = explode(' ',$menu[key($menu)][0]);
            if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
        }// end while
 
    }// end if
}
add_action('admin_menu', 'remove_menus');

* * *

How to Redirect WordPress Feeds to FeedBurner without a Plugin

 

1
2
3
4
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
RewriteRule ^feed/?([_0-9a-z-] )?/?$ http://feeds.feedburner.com/wpbeginner [R=302,NC,L]

* * *

Take Control of your WordPress Admin Bar

 

1
2
3
4
5
6
7
8
9
10
11
12
function my_admin_bar_link() {
	global $wp_admin_bar;
	if ( !is_super_admin() || !is_admin_bar_showing() )
		return;
	$wp_admin_bar-&gt;add_menu( array(
	'id' =&gt; 'diww',
	'parent' =&gt; 'my-blogs',
	'title' =&gt; __( 'Do It With WordPress'),
	'href' =&gt; admin_url( 'http://www.doitwithwp.com/wp-admin.php' )
	) );
}
add_action('admin_bar_menu', 'my_admin_bar_link');

* * *

How To: Inserting Google Maps into WordPress

 

1
2
3
4
5
6
7
8
9
10
//Google Maps Shortcode
function do_googleMaps($atts, $content = null) {
   extract(shortcode_atts(array(
      "width" =&gt; '640',
      "height" =&gt; '480',
      "src" =&gt; ''
   ), $atts));
   return '<iframe src="'.$src.'&amp;output=embed" height="240" width="320" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>';
}
add_shortcode("googlemap", "do_googleMaps");

* * *

Recent Posts With Thumbnails In WordPress Without A Plugin

wordpress-hacks

* * *

Remove post columns

 

1
2
3
4
5
function remove_post_columns($defaults) {
  unset($defaults['comments']);
  return $defaults;
}
add_filter('manage_posts_columns', 'remove_post_columns');

* * *

How to Generate Perfect WordPress Title Tags without a Plugin

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!--?php 
 
if (function_exists('is_tag') &#038;& is_tag()) { 

	echo 'Tag Archive for &quot;'.$tag.'&quot; - '; 
 
} elseif (is_archive()) { 
 
	wp_title(''); echo ' Archive - '; 
 
} elseif (is_search()) { 
 
	echo 'Search for &quot;'.wp_specialchars($s).'&quot; - '; 
 
} elseif (!(is_404()) &#038;& (is_single()) || (is_page())) { 

	wp_title(''); echo ' - '; 
 
} elseif (is_404()) {
 
	echo 'Not Found - '; 
 
}
bloginfo('name'); 
 
?-->

* * *

Random WordPress Quotes Without A Plugin

wordpress-hacks

* * *

Add Social Links to WordPress Without a Plugin

wordpress-hacks

* * *

Comments are closed.