10 useful wordpress coding techniques
TRANSCRIPT
10 Useful WordPress Coding Techniques
As a WordPress user, we must update ourselves with the latest core
functionalities, plugin releases, useful tricks and hacks released by experienced
developers and enthusiasts.The field is growing enormously especially the
WordPress themes market. Therefore the topdevelopers are looking for such
opportunities to get the most out of WordPress.
In this article we will cover some useful tips, code snippets and hacks to help you
to create a WordPress theme.
1.Style Posts Individually
To give a special styling to one or more posts, you can take advantage of both the
post_class() function and the post ID. To apply this trick, just open
your single.php file.
2. Display Related Posts… With Thumbnails!
To keep visitors interested, display a list of related posts. Many plug-ins can do
that, Simply paste this code after the the_content() function in
your single.php file:
<?php
$original_post=$post;
$tags=wp_get_post_tags($post->ID);
if($tags){
echo'<h2>Related Posts</h2>';
$first_tag=$tags[0]->term_id;
$args=array(
'tag__in'=>array($first_tag),
'post__not_in'=>array($post->ID),
'showposts'=>4,
'caller_get_posts'=>1
);
$my_query=newWP_Query($args);
if($my_query->have_posts()){
echo"<ul>";
while($my_query->have_posts()):$my_query->the_post(); ?>
<li><imgsrc="<?phpbloginfo('template_directory');
?>/timthumb/timthumb.php?src=<?phpechoget_post_meta($post->ID,"post-
img",true); ?>&h=40&w=40&zc=1" alt="" /><a href="<?phpthe_permalink() ?>"
rel="bookmark" title="Permanent Link to <?phpthe_title_attribute();
?>"><?phpthe_title(); ?></a></li>
<?phpendwhile;
echo"</ul>";
}
}
$post=$original_post;
wp_reset_query();
?>
3. Antivirus for WordPress
It monitors malicious injections and warns you of any possible attacks.
4. Insert anything into WordPress Blog Post – WP-Insert
A famous WordPress plugin which takes care of all- ads, your feeds, your tracking
codes even the way you edit your posts!
5. Improve page load time – WP Minify
Once enabled, this plugin will combine and compress JS and CSS files to improve
page load time.
6. Custom ‘Read More’ and Thumbnailed Recent Posts
Display a customized Read More message and display related post in Thumbnails
by manipulating WordPress custom fields.
7. Overwrite Post Titles Easily
Simply in single.php file, find the call to the the_title() function and replace it with
the following code:
<?php$title=get_post_meta($post->ID,"custom-title",true);
if($title!=""){
echo"<h1>".$title."</h1>";
}else{ ?>
<h1><?phpthe_title(); ?></h1>
<?php} ?>
8. Add Multiple Sidebars
Open your single.php* file and find the call to the get_sidebar()function:
<?phpget_sidebar(); ?>
9. Auto-Resize Images Using TimThumband WordPress Shortcodes
First create the short code. Paste the following code in your functions.php file:
functionimageresizer($atts,$content=null){
return '<img src="https://media-mediatemple.netdna-ssl.com/wp-
content/uploads/2009/10//timthumb/timthumb.php?src='.$content.'&w=590"
alt="" />';
}add_shortcode('img','imageresizer');
10. WordPress Download Counter
Shows the current download count and even refreshes the count every 15 seconds automatically.
We have published some useful WordPress tips and hacks for all the experienced
WordPress website designer that will help them to create a theme that stands out
from the crowd.
iMediadesigns provide cost effective web design and development solutions and
offers custom web design services in Toronto