Archived topic
Related Posts without GeneratePress Elements Hooks
1 reply · Started by Kulwant on May 13, 2020
How can I add related posts at my blog without using Hooks in GeneratePress Elements?
I have a complete PHP code that I was using earlier, but today I installed on security plugin which is not allowing GP PHP hooks to execute.
Now I want to hardcode that code in function.php file itself.
Can anyone give me the code to add in my function.php file?
Keeping in the mind that I have PHP code to display related posts already with me. :)
One friend gave me this code, but it's not working.
//After Entry Content
add_action( 'generate_after_entry_content ','example_function_name' );
function example_function_name() {
Insert your hook contents in here.
}
Hi there,
You can use the PHP Snippet to allow Hooks to execute PHP without enabling it anywhere else:
https://docs.generatepress.com/article/generate_hooks_execute_php/
If you want the PHP method then the problem you have is the incorrect Hook Name.
Try:
add_action( 'generate_after_content','example_function_name' );
function example_function_name() {
// Your function goes here
}
You can see all the of main hooks here: