WordPress.org

Support

Support » Miscellaneous » [Resolved] Proper / faster way to use PHP in WP themes?

[Resolved] Proper / faster way to use PHP in WP themes?

  • Hello,
    I am trying to make my first WP theme, but I’m unsure about what is the best way of mixing PHP and HTML in there. What has me the most confused is that in TwentyTen and many other themes, PHP open and closing tags are used every line – even if it’s continuous PHP code with no HTML – like this:

    <?php if ( $post->post_type == 'post' ) { ?>
    <?php edit_post_link(); ?>
    <?php } ?>

    Sometime ago I was told that opening and closing PHP tags should be avoided as it slows down things? What’s the difference between the example above and below, and which is better/faster or correct way to do this?

    <?php if ( $post->post_type == 'post' ) {
    edit_post_link();
    } ?>

    Thanks.

Viewing 1 replies (of 1 total)
  • esmi

    @esmi

    Forum Moderator

    I actually prefer the second code example to the first but that’s a purely personal preference. In the grand scheme of things, I don’t think that the opening & closing php tags really have much of a performance effect either way.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Proper / faster way to use PHP in WP themes?’ is closed to new replies.
Skip to toolbar