I need to put code right before comments on a static page

Discussion in 'WordPress' started by Oberon, May 1, 2010.

  1. #1
    I need to put some code right before the comments section on a static Wordpress page (those that have links in the main menu) -- which php file do I have to edit and where should the code go?

    Many thanks!
     
    Oberon, May 1, 2010 IP
  2. extremephp

    extremephp Peon

    Messages:
    1,290
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If it is on the index or home page, edit index.php or if it is for single post page, edit single.php... make sure you are editing these of the templates and not the wordpress as it is :)

    Go to theme editor to make it done easily..! :)
     
    extremephp, May 1, 2010 IP
  3. Oberon

    Oberon Well-Known Member

    Messages:
    112
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    125
    #3
    It is neither the home page nor a post -- it is a new page created with Pages --> add new.

    I need to put code before the comments just for this page. It must not affect any other page.

    Thanks!
     
    Oberon, May 1, 2010 IP
  4. rilwis

    rilwis Peon

    Messages:
    104
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The page template file is page.php, but the comment section is in comments.php file. So, I guess the file you need to edit is comments.php.

    To show code in only static page, use the condition:

    
    <?php
    if (is_page()) {
    // your code here
    }
    ?>
    
    PHP:
     
    rilwis, May 2, 2010 IP
  5. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #5
    What kind of code. If it's javascript you might try inserting it in the HTML mode rather than visual. Or if it's a php script you can try:

    http://wordpress.org/extend/plugins/exec-php/

    Just use it on the page you want to edit rather than a template.
     
    bob25, May 2, 2010 IP