Support » Fixing WordPress » Trying to remove output in comments.php

  • Hello!
    Bit of a newbie PHP issue really – I’m trying to move some code from my comments.php file.

    This is it: '<em>' . get_the_title() . '</em>

    I’ve tried stripping it out, but it doesn’t work. It’s a bit more involved than I first thought – and I’m not sure how to strip out the PHP without crashing my site!

    Here’s an example from a page on my travel blog. The text “Travel Photo of the Day: Ki Monastary in the Spiti Valley” is wrapped in the tags – I’d like that all gone and for it just to say: “2 Comments – Add Yours!”

    Here’s all the code from my comments.php file:http://pastebin.com/1vTeH6mA

    Any tips would be excellent! Thanks very much 🙂

    Best regards,
    Stuart Edwards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The file says it’s not your comments.php, but a comments.php belonging to WooFramework. Don’t edit files that don’t belong to you, because your changes will be overwritten by updates and you’ll have to do all the work again. Use a child theme to replace comments.php with your own copy, and change the header comments so that it’s obvious which version you’re editing.

    Stripping out the part of the code you don’t want shouldn’t cause a problem, but you have to ensure that the quotes remain properly paired. Remove exactly this and no more:

    <em>' . get_the_title() . '</em>

    (You’ve removed exactly two quotes, so the pairing will not be affected.)

    That’s great Rod thank you!

    Time to learn PHP me thinks 🙂

    I’ve been looking into child themes for the canvas theme – A lot of the stuff I’ve read is just about the custom.css and functions.php files – But I’ve got a ton of other core php files I’ve edited I’d need to put in the child theme.

    Any ideas?

    Thanks!

    You can copy template files from the parent theme into the child theme, where you can edit them.

    There is no good way to edit files that belong to WordPress itself. Instead, in your template’s functions.php, use actions, filters and pluggable functions if you want to change the way WordPress works. Doing it this way will allow you to upgrade WordPress as new versions are released.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trying to remove output in comments.php’ is closed to new replies.