How to Add Custom Code Above the Comments In Thesis

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><img 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.

10 thoughts on “How to Add Custom Code Above the Comments In Thesis

  1. 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. ๐Ÿ˜€

  2. 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 ๐Ÿ™‚

  3. 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.

  4. 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

Leave a Reply

Your email address will not be published.