5 Easy Ways to Righteous WordPress Coding


WordPress is considered to be the most user-friendly and easy to use content management system. Even a lay man, who has zero technical knowledge can build and manage websites using WordPress. No such need of touching the back-end coding ever arises while you are using this scalable CMS. There are, however, instances when some issues arise that might need to be addressed technically.

You may even need to do some hard core coding. What would you do in such situations? Panic? Call for help? Well, we suggest you to just keep reading. Yes! It might sound unbelievable but to deal with day to day coding issues in WordPress, all you need is a editing compatible WordPress website and some basic know how about PHP coding and you can tackle your WordPress coding issues like an expert. Here are some great tips that will assist you further in becoming a WordPress pro.

Getting Custom Field Value

If you are dealing with thumbnails in your WordPress site, this tweak can be very helpful for you. Custom fields in WordPress can be used for directly transferring values from the code into your posts. There are several functions that can be used for this purpose. Two most commonly used functions are listed below:

1
2
3
4
5
<b>Function 1</b>
$thumbnail = get_post_meta($post->ID, 'thumb', $single = true);
 
<b>Function 2</b>
$image = get_post_custom_values('img');

Displaying Content on Front Page Only

If there is some specific content that you are willing to show only on the front page of your blog, then you can use the following code snippet to do so:

1
2
3
4
5
6
7
<?php
 if ( is_home() ) {
 // This is a homepage
 } else {
 // This is not a homepage
 }
 ?>

Adding Content in Between Posts

There are times when you want to add a post in between already published two posts. What will you do in that situation? Well, here is a tweak from PHP that can help you handle things and do as you desire even in this tricky situation. Here is the PHP loop that you will need to edit for the purpose. You will find this loop in your index.php file:

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 (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div>
<?php the_content('Read the rest of this entry &amp;raquo;'); ?>
</div>
<?php endwhile; ?>
<?php else : ?>
 <b>Not Found</b>
<?php _e("Sorry, but you are looking for something that isn't here."); ?>
<?php endif; ?>
Now, that you have found this code file, here is how you can add content in between posts:
<?php if (have_posts()) :
$i = 1; // We will created variable with 1 as initial value
while (have_posts()) : the_post();
if($i == 5){// check if the value of $i is 1
//Show Content before the fifth article
}; ?>
<div>
<?php the_content('Read the rest of this entry &amp;raquo;'); ?>
</div>
<?php endwhile;
$i++; //This is to add 1 in current value of $i
 else : ?>
<b>Not Found</b>
<?php _e("Sorry, but you are looking for something that isn't here."); ?>
<?php endif; ?>

Knowing the Subscriber Count for FeedBurner

Knowing the subscriber count of your FeedBurner account is now simple. Just add the following code snippet to your WordPress back-end and you are good to go. Just, remember to replace the FeedBurner-Id with your own Id.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";
//Initialize the Curl session
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $whaturl);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//end get cool feedburner count
Adding Breadcrumbs to your Wordpress Blogs:
You can add breadcrumbs to your site using various plugins that are available online. Moreover, you can also use the following code snippet:
<div class="breadcrumbs">
if(function_exists('bcn_display'))
{
bcn_display();
}
?>
</div>

Author
Steve Graham is a Java expert who has industry expertise in Java web development and J2EE application development. He is currently supervising Enterprise Java development projects as a senior developer at Xicom Technologies ltd, an offshore software development company.

Recently Published

»

Importance and actions of cloud computing in e-commerce business

The e-commerce industry is growing in leaps and bounds, and, ...

»

How to remove Options from One Select Box and retain One Option?

One can easily remove  options of a select box from HTML and append ...

»

How to Ensure that Users Do Not Deactivate The Critical WordPress Plugins

It’s no secret that among all the remarkably useful features of ...

»

How to scroll to the top of a webpage using jQuery ?

If you are looking for an extraordinary method of smoothly scrolling ...

»

11 sources to gain perfect knowledge of html5 semantic tags

1. Html5tuts Html5tuts is a site dedicated to HTML5. Feel free to ...

»

How to move an element into another parent element using jQuery?

An important piece to the puzzle when coding with jQuery is that how ...

»

10 optionally Good WordPress Typography Plugins You could Opt For

It is not necessary that the person will follow the standard guide ...

»

8 creative 3d slider wordpress themes to keep your blog active

1. Display Display is a WordPress Theme best used for Portfolio and ...

»

11 quick remote screen sharing apps worth trying

1. Join Me Easy to start, easy to join, easy to manage, join.me takes ...