This wordpress themes hack has tested. Modifying the wordpress themes code can cause your wordpress themes error. We cannot guarantee that problems resulting from modifications the wordpress themes. Use this tutorial at your own risk. I have tried all that mentioned here in wordpress 2.7, wordpress 2.7.1 and wordpress 2.8 and all wordked.
A. Embed Google Adsense In First WordPress Post
To place an ad after the first post title in your WordPress blog main page
Source: http://www.devtopics.com/embed-google-ad-in-first-wordpress-post/
B. Adding Comment Numbers To Your WordPress Theme
Here are the steps you can take to easily add numbers to your WordPress theme’s comments section.
Source: http://wphacks.com/how-to-adding-comment-numbers-to-your-wordpress-theme
C. Separate WordPress Comments and Trackbacks
D. Display the most commented posts
Copy and paste following code to your wordpress themes to display most commented post.
E. WordPress Recent Posts from specific category
A. Embed Google Adsense In First WordPress Post
To place an ad after the first post title in your WordPress blog main page
- Open the WordPress admin control panel and navigate to: Presentation > Theme Editor
- Select the Main Index Template (index.php) from the list of templates on the right.
- In the Main Index Template, find the line that starts with:
<?php if (have_posts())
- Add the following line above it:
<?php $count = 1; ?>
- Next, find the line that starts with:
<?php the_content
- After the closing tag ?> for that section (it may wrap to multiple lines), add the following code:
<?php if ($count == 1) : ?>
– Insert your Google AdSense code here –
<?php endif; $count++; ?> - Click Update File.
Source: http://www.devtopics.com/embed-google-ad-in-first-wordpress-post/
B. Adding Comment Numbers To Your WordPress Theme
Here are the steps you can take to easily add numbers to your WordPress theme’s comments section.
- First thing you will want to do is create a backup your comments.php file.
- Locate the comments.php file.
- Locate the code that starts the comment loop. It will look something like this:
<?php if ( $comments ) : ?>
- Place this code immediately above the code in Step 3:
<?php $i = 0; ?>
- Now locate the code that looks like this:
<?php foreach ($comments as $comment) : ?>
- Placed this code immediately below the code in Step 5:
<?php $i++; ?>
- Now use this code where you want to display your comment numbers:
<span class=”count”>
<?php echo $i; ?>
</span> - Click Save.
- Now go to your stylesheet (style.css) and place this code anywhere on the stylesheet (probably best placed in the comments section):
.count {
float:right;
padding: 10px;
font-size:18px;
color:#000000;
}
Source: http://wphacks.com/how-to-adding-comment-numbers-to-your-wordpress-theme
C. Separate WordPress Comments and Trackbacks
- Access your comments.php file and locate the following code:
<?php foreach ($comments as $comment) : ?>
- Immediately after the above code, you’ll want to place this code:
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == ‘comment’) { ?> - Next, you’ll want to scroll down a little bit and locate the following code:
<?php endforeach; /* end for each comment */ ?>
- Immediately before the above code, you’ll want to place this code:
<?php } /* End of is_comment statement */ ?>
This will filter out all of the trackbacks and pingbacks from your main comments loop. Now we need to create a second comments loop to display the trackbacks and pingbacks. - Almost immediately below the code from step 2 you should find this code:
<?php else : // this is displayed if there are no comments so far ?>
Immediately before the above code, you’ll want to place this code:
<h3>Trackbacks</h3>
You can adjust this code to display how you want to, including using a different header if you have a specific look for your header 3.
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != ‘comment’) { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
D. Display the most commented posts
Copy and paste following code to your wordpress themes to display most commented post.
<h2>Most commented posts</h2>Source: http://www.wprecipes.com/how-to-display-the-most-commented-posts-of-2008
<ul>
<?php
$result = $wpdb->get_results(“SELECT comment_count,ID,post_title, post_date FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10″);
foreach ($result as $topten) {
$postid = $topten->ID;
$title = $topten->post_title;
$commentcount = $topten->comment_count;
if ($commentcount != 0) {
?>
<li><a href=”<?php echo get_permalink($postid); ?>”><?php echo $title ?></a></li>
<?php }
}
?>
E. WordPress Recent Posts from specific category
<ul>Replace catID with post category to be displayed.
<?php $recent = new WP_Query(“cat=catID&showposts=10″); while($recent->have_posts()) : $recent->the_post();?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark”>
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>
No comments:
Post a Comment