Archived topic
"Posts" pages give php error
7 replies · Started by Tijn on February 27, 2020
For some reason the blogposts give php error.
I debugged it with deactivating plugins and changing themes. When I deactivate GP Premium plugin. Problem is fixed. But styling is than not correct anymore.
Hi there,
I don't believe this would be a GP Premium issue.
Have you added any header or hooks elements?
https://docs.generatepress.com/article/header-element-overview/
https://docs.generatepress.com/article/hooks-element-overview/
If so what happens if you disable them?
Let me know :)
Hi Leo,
Thanks! Thats correct. It has to do with the Custom Post Header it seems. But I haven't edited it myself. Is there a way to fix this, or could you see what's wrong with the code?
<?php
$img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large', false );
$categories = get_the_category();
if ( ! empty( $categories ) ) {
$cat_name = esc_html( $categories[0]->name );
}
global $post
?>
<?php echo 'term_id ) ) . '">' . esc_html( $categories[0]->name ) . ''; ?>
Hi there,
so this is the reason that script is not firing:
https://docs.generatepress.com/article/disallow-php-execution/
Which may be your default wp-config or something a security plugin has added.
If you want you can overcome this to allow PHP to be executed in GP Hooks only using the snippet provided here:
https://docs.generatepress.com/article/generate_hooks_execute_php/
Hi David,
Thanks for this. Learned a lot again. It's indeed correct that the define( 'DISALLOW_FILE_EDIT', true ); was activated by the security plugin iThemes. I deleted this constant and after re-updating the Element it works again. But without the security measurement. The snippet doesn't seems to work together with the disallow file edit.
- I added the snippet using the Cope Snippits plugin, no changes
- I added the snippet in wp-config.php -> blank page
Could you maybe suggest some other solutions?
For now it works again. Thanks!
Best, Tijn
So if you re-enable the iThemes security constant ( so the element breaks )
And add this to Code Snippets:
https://docs.generatepress.com/article/generate_hooks_execute_php/
Does it still not work ?
Yes it works now.
But I first had to add the Cope Snippet and activate it before re-enabling the iThemes security plugin + constant. Otherwise it doesn't got it.
Thanks for all the help!
Aah right - i suppose thats good security :) Thanks for letting us know.