WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Proper / faster way to use PHP in WP themes? (2 posts)

  1. chadrew
    Member
    Posted 3 years ago #

    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.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags