Archived topic
Hooks add odd code to the theme
15 replies · Started by ETO on November 22, 2020
Hello,
When I try to add breadcrumbs as explained here: https://docs.generatepress.com/article/adding-breadcrumbs/, the hook adds some odd codes into the theme instead of breadcrumbs.
Have look at the screenshot to see the odd code, please.
Hi there,
Did you check the Execute PHP checkbox?
Yes, I checked the Execute PHP checkbox, but there is still the same problem.
I tried both using shortcode and the php code of Yoast, but no change.
Hi,
Can you provide screenshots of the code you've added so we could check for any syntax issues?
Alternatively, you can provide us temporary site access so we could check directly.
You can use the private information text field. Thank you. :)
Hi, Elvin!
I sent you temporary site access so that you could check directly.
Hi,
Your hook has this issue:
"Unable to execute PHP as DISALLOW_FILE_EDIT is defined."
Here's an article on how to address this:
https://docs.generatepress.com/article/disallow-php-execution/
A few days ago, there was this code: define( 'DISALLOW_FILE_EDIT', TRUE );But, then, we changed it like this: define( 'DISALLOW_FILE_EDIT', FALSE );
So I don't understand why you still got this error: “Unable to execute PHP as DISALLOW_FILE_EDIT is defined.”
A few minutes ago, we deleted this line of code from wp-config-php file completely: define( 'DISALLOW_FILE_EDIT', FALSE );
So, could you please check the issue again?
Hi there,
there may be other security settings on the server ( or in a plugin ) that is disallowing PHP editing.
Instead of editing the config file, you can add the PHP snippet provided here, this will allow PHP execution just in the Hook element:
https://docs.generatepress.com/article/generate_hooks_execute_php/
The problem is not with just adding breadcrumbs php code, the problem occurs when we add breadcrumbs shortcode or any other code as well.
The only element i see that requires PHP enabling is: Breadcrumbs - currently the PHP option is not checked
That element is not active as it adds odd code to my site. I sent you my login info so that you can make any necessary changes such checking the PHP option or not, add shortcode or the php code to see if it works or adds the odd code I mentioned before.
I enabled the Breadcrumb hook and set its Display Rule location to Posts > All Posts.
The breadcrumb is now displayed.
Thank you, David. I added category as display location apart from post. But breadcrumbs appear above all titles of the post on the category page. Please, check the screenshot and link I sent you.
Hi,
But breadcrumbs appear above all titles of the post on the category page. Please, check the screenshot and link I sent you.
This occurs because your Hook Element is hooked on generate_before_entry_title. The Hook element is being placed on all entry-title on the page, including the post entry-title.
To address this, simply change the hook on the Breadcrumbs hook element.
Here's a visual guide on all the hooks and where they appear:
https://docs.generatepress.com/article/hooks-visual-guide/
Perhaps generate_inside_container_hook or generate_before_main_content fits your preference.
Thank you, Elvin. It is OK now.