- This topic has 7 replies, 4 voices, and was last updated 2 years, 11 months ago by
David.
-
AuthorPosts
-
February 6, 2020 at 7:01 pm #1157260
Elaine
I created an action hook using your documentation, and using an Element. This is to add a photo to the top of the category page. I must be doing something wrong because the code is visible on the front end!
February 6, 2020 at 9:54 pm #1157337Leo
StaffCustomer SupportHi there,
Sorry what’s the code you are adding?
If it’s PHP then make sure to check execute PHP.
Let me know ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 7, 2020 at 5:30 am #1157757Elaine
Thanks Leo. You were right, I did not execute PHP. However, when I do execute PHP in Elements, now there is an error on the front end, and it breaks the page:
Parse error: syntax error, unexpected ‘}’ in /home1/chance/public_html/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()’d code on line 4Here is my original code:
add_action( 'generate_before_main_content','es_insert_photo' ); function es_insert_photo() { ?> <img src="/wp-content/uploads/cheers.jpg" alt="Glasses of wine clinking together among friends." /> <?php }
February 7, 2020 at 6:29 am #1157830David
StaffCustomer SupportHi there,
you don’t need to use the
add_action
function as this is what the Hook Element is doing.
You simply need to add the Content you wish to display eg.<img src="/wp-content/uploads/cheers.jpg" alt="Glasses of wine clinking together among friends." />
Select the
before_main_content
hook from the list.This won’t require Execute PHP to be checked
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 7, 2020 at 6:36 am #1157841Elaine
Thanks David, that worked I was overthinking it!
February 7, 2020 at 6:38 am #1157842David
StaffCustomer SupportYou’re welcome ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/February 10, 2020 at 6:18 pm #1161227mtevansadmin
David,
We have a related question to this topic and getting similar parse error or visible code on site. Could you please provide an example for an instance such as ours when you do need to execute PHP within the Hook Elemnt? We are trying to remove_action / add_action in order to move secondary nav to above footer but have tried 50 ways to Sunday to make it work and nada. From GP’s forum in 2014 Tom assisted someone when it was just the HOOKs method, but using ELEMENT has us scratching our heads. The basic content functionality we want to implement below while using Hook “before_footer”. Thanks so much!{
remove_action( ‘generate_before_header’, ‘generate_add_secondary_navigation_before_header’ );
add_action( ‘generate_before_footer’, ‘generate_add_secondary_navigation_before_header’ );
}February 11, 2020 at 3:52 am #1161593David
StaffCustomer SupportHi there,
so moving the Secondary Nav to a new hook using Elements would require two things:
1. In Customizer > Layout > Secondary Navigation – set the Location to:
No navigation
. This is the equivalent of theremove_action
call2. For your Hook Element you can use this snippet to call the secondary navigation:
<?php if ( function_exists( 'generate_secondary_navigation_position' ) ) { generate_secondary_navigation_position(); } ?>
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.