How to Add Custom Code Above the Comments In Thesis

by The Birdfreak Team on January 22, 2009

in Blogging

Thesis is the easy to use, highly functional WordPress coding framework that runs Birdfreak.com. This is a simple way to add custom code in a place where there is no hook designated for it: right before the comments begin. This tutorial is for Thesis Version 1.3.3. and will allow you to customize similar to what is visible at copyblogger.

UPDATE: Thanks to Rick Beckman, Thesis coding expert, we finally figured out a more efficient way to do this. Please see below ☟ (Add your own styling and commentary as you see fit.)

Insert the following code into your custom_functions.php file:

function thesis_advert_post() { ?>
<?php
if (is_single()) { ?>
<?php echo "<div id=\"thesis-ad\"><h3>Birdfreak.com Runs on Thesis</h3>
<p>&ltimg class=\"rightframe\" src=\"http://birdfreak.com/thesis-screenshot.png\" width=\"200\" />Thesis is the world's best <a href=\"http://www.wordpress.org\">WordPress</a> theme whether you are just beginning a blog or running a fully featured online publishing business. With its amazing ability to customize and the groundbreaking use of hooks to arrange content, even non-code geeks can easily get on board.</p>
</div>"; }
?>
<?php
}
add_action('thesis_hook_after_post', 'thesis_advert_post');

Check out our complete review of Thesis and you’ll soon know why it is the best WordPress theme out there.

Using a program such as Adobe Dreamweaver CS4 (we use CS3), open up the file called comments.php. At the beginning of the file paste the following code:

<?php
echo "<div id="your custom style"><h3>Custom Heading</h3>
<p>Your custom text, images, and links.</p>
</div>";
?>

This code can be altered to include as much or as little as possible and is only for example. The way you style it depends on your design. By adding this code into your comments.php file it will only display when the full post is being viewed and will show above the comments just like you see below.

    

{ 9 comments… read them below or add one }

1 John Briggs January 22, 2009 at 6:04 pm

I think I am falling in love with this Thesis theme! Thanks for the links. I think I will be changing my theme in the next week or so.

2 Rick Beckman January 23, 2009 at 1:38 am

The proper way would be to use the thesis_hook_after_post, wrapping the code to be output there in a conditional such as is_single(). Pretty sure that’s how Chris did the customization for Copyblogger; at the very least, I’ve done very similar on my own sites. This can all be done in custom_functions.php, making the change future-proof. :D

3 The Birdfreak Team January 23, 2009 at 8:30 am

Thanks Rick! I tried dropping the code into various places while trying to get it to show up where I wanted it. However, it “fired” for every post but I only wanted it when the post was viewed and not for each post. I haven’t used the is_single() so thus did not realize that is how to control it. I will have to implement it that way but needed the quick fix first :)

4 Adrian May 10, 2009 at 10:28 am

how can i add code for example a 486*60 pixel Google Adsense banner to the Header ????

5 The Birdfreak Team May 12, 2009 at 11:49 am

To add anything to the header you need to hook it under thesis_hook_before_header. Check out DIYthemes Hook Usage for code examples on how to do this. I hope that helps. A lot of what I’ve done with Thesis has been a combination of trial and error and reading through other people’s sites and the amazing Thesis forum.

6 Inger V Johannessen August 11, 2009 at 6:07 am

Hi
Working on my blog and I am very new to it all, there are a couple of things I would like to change.
First – I would like to change “Comment” to for example “Speak up! Comment! Show you are Alive!”
How do I change set headings in Thesis?
Second – How do I get the comment box to show the same as you have here when people want to comment?
Thanks for your help.

Inger

7 Inger V Johannessen August 11, 2009 at 7:46 am

Found it! Everything is great. Thanks for a great site!

Inger

8 The Birdfreak Team August 11, 2009 at 7:50 am

Inger – this should provide the info you are looking for the first part: http://www.thesishacker.com/change-leave-a-comment-text-to-something-else

I’m not sure about part two. I haven’t really edited that specifically. Can you explain further what you want to do or link to a test site of what you are currently getting.

Hope that helps, Eddie “Birdfreak”

9 The Birdfreak Team August 11, 2009 at 9:29 am

Inger – you are most welcome and come back often for more blogging info!!

Leave a Comment

{ 1 trackback }

Previous post:

Next post: