• Resolved jonand_se

    (@jonand_se)


    I am a newbie to WordPress development, and PHP, so my problem is maybe a dummy error. Anyway, I have created a child theme to the Twenty Eleven theme as suggested as the smart way for customization of a theme and the customization I want to do is to hide the website field in comments.

    So I added this code (full file shown) to functions.php in the child theme folder

    <?php
    
    add_filter('comment_form_default_fields', 'url_filtered');
    function url_filtered($fields)
    {
      if(isset($fields['url']))
       unset($fields['url']);
      return $fields;
    }
    
    ?>

    And it works. The website field is hidden. But the PHP code is shown as one long unindented line of text in the top of pages that contains the comments form. Are there any simple explanation to this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator cubecolour

    (@numeeja)

    Please provide a link to your site.

    Thread Starter jonand_se

    (@jonand_se)

    This is embarrassing but I can’t reproduce it now. When I wrote the post above could I with both Firefox and IE on two different computers, as I didn’t trust my browser cache (but I emptied it also). Could there be any lag after changes are done? Anyway I can’t reproduce this right now but it works just fine! I should of course have provided a link already before and the problem showed on for example this page before http://blog.java.jonand.se/sample-page/ (which I will rename to /about soon)

    Moderator cubecolour

    (@numeeja)

    Your site appears to be using a cache plugin. This would explain the lag.

    Thread Starter jonand_se

    (@jonand_se)

    Oups! Yes it does! The WP Super Cache. But I said that I am new to WP development. This seems to be the apparent explanation. I have seen other strange behavior that also can be explained of this. Now I will try to remember to clear that cache every time I want to see the result immediately after an update.

    Thanks! This was very helpful!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP code shown in the browser’ is closed to new replies.