Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] Hooks add odd code to the theme

Home Forums Support Hooks add odd code to the theme

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1541345
    ETO

    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.

    #1541391
    Leo
    Staff
    Customer Support

    Hi there,

    Did you check the Execute PHP checkbox?

    #1541443
    ETO

    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.

    #1541455
    Elvin
    Customer Support

    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. 🙂

    A wise man once said:
    "Have you cleared your cache?"

    #1543017
    ETO

    Hi, Elvin!
    I sent you temporary site access so that you could check directly.

    #1543041
    Elvin
    Customer Support

    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 wise man once said:
    "Have you cleared your cache?"

    #1543569
    ETO

    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?

    #1543797
    David
    Staff
    Customer Support

    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/

    #1543827
    ETO

    The problem is not with just adding breadcrumbs php code, the problem occurs when we add breadcrumbs shortcode or any other code as well.

    #1543853
    David
    Staff
    Customer Support

    The only element i see that requires PHP enabling is: Breadcrumbs – currently the PHP option is not checked

    #1544037
    ETO

    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.

    #1544043
    David
    Staff
    Customer Support

    I enabled the Breadcrumb hook and set its Display Rule location to Posts > All Posts.
    The breadcrumb is now displayed.

    #1545032
    ETO

    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.

    #1545337
    Elvin
    Customer Support

    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.

    A wise man once said:
    "Have you cleared your cache?"

    #1546060
    ETO

    Thank you, Elvin. It is OK now.

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.