Pages

Ads 468x60px

Sunday 9 September 2012

WordPress Themes Hack

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

  1. Open the WordPress admin control panel and navigate to: Presentation > Theme Editor
  2. Select the Main Index Template (index.php) from the list of templates on the right.
  3. In the Main Index Template, find the line that starts with:
    <?php if (have_posts())
  4. Add the following line above it:
    <?php $count = 1; ?>
  5. Next, find the line that starts with:
    <?php the_content
  6. 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++; ?>
  7. Click Update File.
This places the ad within the first post.  If instead you want the ad to appear between the first and second post, add the code from step 6 after the closing </div> tag for the “entry” div that contains the line <?php the_content.
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.
  1. First thing you will want to do is create a backup your comments.php file.
  2. Locate the comments.php file.
  3. Locate the code that starts the comment loop. It will look something like this:
    <?php if ( $comments ) : ?>
  4. Place this code immediately above the code in Step 3:
    <?php $i = 0; ?>
  5. Now locate the code that looks like this:
    <?php foreach ($comments as $comment) : ?>
  6. Placed this code immediately below the code in Step 5:
    <?php $i++; ?>
  7. Now use this code where you want to display your comment numbers:
    <span class=”count”>
    <?php echo $i; ?>
    </span>
  8. Click Save.
  9. 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;
    }
You can adjust the stylesheet to fit your comment numbers into the placement and appearance that you want them to have.
Source: http://wphacks.com/how-to-adding-comment-numbers-to-your-wordpress-theme
C. Separate WordPress Comments and Trackbacks
  1. Access your comments.php file and locate the following code:
    <?php foreach ($comments as $comment) : ?>
  2. Immediately after the above code, you’ll want to place this code:
    <?php $comment_type = get_comment_type(); ?>
    <?php if($comment_type == ‘comment’) { ?>
  3. Next, you’ll want to scroll down a little bit and locate the following code:
    <?php endforeach; /* end for each comment */ ?>
  4. 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.
  5. 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>
    <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>
    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.
Source: http://wphacks.com/how-to-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.
<h2>Most commented posts</h2>
<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 }
}
?>
Source: http://www.wprecipes.com/how-to-display-the-most-commented-posts-of-2008
E. WordPress Recent Posts from specific category
<ul>
<?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>
Replace catID with post category to be displayed.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
trickstipsall4u.blogspot.com Webutation
MyFreeCopyright.com Registered & Protected

M

ad

Contact Me

flagcounter

free counters