[resolved] Weird bug: WordPress auto convert PHP to HTML code (5 posts)

  1. Tien Nguyen
    Posted 2 years ago #

    Dear all,

    I just install a new Centos server with Ngnix and php-fpm.

    Now, I am develop a template with my site at: bloggeritems.com
    But a weird error is when I code like below:

    <div class="blog-info">
    				<?php $fname = 'Blogger Items'; ?>
    				<?php if ( is_archive() ) : ?>
    					<h1 class="site-title"><?echo $fname;?></h1>
    				<?php else : ?>
    					<h2 class="site-title"><?echo $fname?></h2>
    				<?php endif; ?>
    				<p class="site-description"><?php bloginfo( 'description' ); ?></p>

    The output result will like below:

    <div class="blog-info">
    									<h2 class="site-title"><!--?echo $fname?--></h2>
    				<p class="site-description">Blogger and Blogspot Organization created amazing templates, widget, guide, tips, discussions and all free for you.</p>

    Mean <?echo $fname;?> in PHP will become <!--?echo $fname?--> in HTML
    This is WP bug or I am a noob?

    Appreciate all helps.

    Best regards,
    Tien Nguyen

  2. Ken Mackenzie
    Posted 2 years ago #

    Looks like you probably dont have php shortcodes enabled so that php code that begins with "<?" is not recognised and therefore the code not executed. For example <? Echo $fname; ?>...

    In your php.ini file on your server, search for and then make sure the following line is set as follows, then restart your web server software:


    That should fix it.



  3. Ken Mackenzie
    Posted 2 years ago #

    Or else , change all instances of <? to <?php


  4. Tien Nguyen
    Posted 2 years ago #

    Dear Ken,

    Thank for your suggestion, it's working now. I found NGNIX can not process <?, you must use <?php.

    Best regards,

  5. davewatts
    Posted 2 years ago #

    you could try this php/js/smarty online formatting tool, if you get stuck


Topic Closed

This topic has been closed to new replies.

About this Topic