Jwest100 Posted December 13, 2016 Share Posted December 13, 2016 I have this html with a php statement embedded: <div style="text-align:center;<?php if(!get_post_meta(get_the_ID(), 'buy_status', true)): ?>display: block;<?php else: ?>display: none;<?php endif; ?>> content </div> However the php isn't getting evaluated. It is simply showing as text in the source code. What am I doing wrong?? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/ Share on other sites More sharing options...
Jacques1 Posted December 13, 2016 Share Posted December 13, 2016 Are you sure the file has a “.php” extension? Are you sure the webserver is configured to execute PHP scripts in this directory? Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540291 Share on other sites More sharing options...
Jwest100 Posted December 13, 2016 Author Share Posted December 13, 2016 Oh yes. No problems there. Site is php Wordpress and ha been running fine for months. Just adding a customization and I'm clueless on how this statement should be configured in order to work Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540295 Share on other sites More sharing options...
Jacques1 Posted December 13, 2016 Share Posted December 13, 2016 I'm talking about this specific file, not your site in general. If the code isn't executed, that's clearly not fine. Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540296 Share on other sites More sharing options...
Jwest100 Posted December 14, 2016 Author Share Posted December 14, 2016 Yes. It is config'd to execute php. Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540310 Share on other sites More sharing options...
Jwest100 Posted December 14, 2016 Author Share Posted December 14, 2016 And yes it has a php extension. The php statement is inside a Wordpress post. Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540311 Share on other sites More sharing options...
benanamen Posted December 14, 2016 Share Posted December 14, 2016 The php statement is inside a Wordpress post. And there's your "problem". Wordpress is not going to run code in a post. That would be a MAJOR security problem if it did. Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540336 Share on other sites More sharing options...
cyberRobot Posted December 14, 2016 Share Posted December 14, 2016 For what it's worth, there are plugins that let you run PHP code inside a WordPress post. I haven't used any of the plugins...and I haven't looked into the potential security risks of adding one. Hopefully the plugin wouldn't allow visitors to run PHP code through the blog post comments section, for example. Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540338 Share on other sites More sharing options...
maxxd Posted December 14, 2016 Share Posted December 14, 2016 And there's your "problem". Wordpress is not going to run code in a post. That would be a MAJOR security problem if it did. It does let you run JavaScript willy-nilly in a post or page body though, so there's always that... Quote Link to comment https://forums.phpfreaks.com/topic/302730-php-in-html-not-evaluating-help-needed/#findComment-1540351 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.