Archived topic
Feature request: Allow php in Sections
3 replies · Started by Pete on November 1, 2019
I'd like to see php be able to be applied inside Sections indirectly via a GP Hook or directly in the content of the Section.
Hi there,
this topic explains how to create a Shortcode that will output your own custom hook:
https://generatepress.com/forums/topic/hook/#post-1036765
Then you can add the shortcode where you want and use the Custom Hook option in the Hook Element.
I'd like something easy like in Hooks as some of my php is long and complex.
Hooks are a WP function that do not and cannot exist within the_content of your posts, whether that be the classic WP editor or GP Sections. The method i provided above is the only way of adding a hook to the content. Once the shortcode is setup then you can use GP Hook Element or write your own add_action function to hook in your code.