- This topic has 13 replies, 2 voices, and was last updated 7 years, 2 months ago by Tom.
September 30, 2015 at 3:09 pm #141050Andreas
I have copied the file single.php and changed this.
<?php /** * The Template for displaying all single posts. * * @package GeneratePress */ get_header(); ?> <div id="primary" <?php generate_content_class();?> itemprop="mainContentOfPage"> <main id="main" <?php generate_main_class(); ?> itemtype="http://schema.org/Blog" itemscope="itemscope" role="main"> <?php do_action('generate_before_main_content'); ?> <?php while ( have_posts() ) : the_post(); ?> <?php $meta_values = get_post_meta( get_the_ID() ); ?> ............
I have a hook created in “befor header” . It works fine but not on the page for which I created the template.September 30, 2015 at 8:14 pm #141101TomLead DeveloperLead Developer
Where’s the before header hook? If you’re just using the built in GP
generate_before_headerhook, it will be included in the
get_header()function you see there, so I don’t think the problem is with your single.php file.October 1, 2015 at 2:59 am #141139Andreas
Sorry, the Hook is set in “before content”!October 1, 2015 at 10:42 am #141186TomLead DeveloperLead DeveloperOctober 1, 2015 at 11:41 am #141201Andreas
The hook is available and will work on all sides except on its own single.php and archive.php for the category “vehicles”October 1, 2015 at 11:58 am #141205Andreas
I’ve replaced the function
<?php get_template_part( 'content', 'single' ); ?>by meta tags. When I insert it again the hooks will run!
Any Ideas…?October 1, 2015 at 1:01 pm #141229Andreas
When I use
<?php do_action( 'generate_before_content'); ?>instead the Hook is working but I have a problem with view.
Normally, the first image should not be loaded.
Please delete the posted URL!October 1, 2015 at 1:19 pm #141240TomLead DeveloperLead Developer
The generate_before_content hook runs inside the content-single.php file.
When making custom page templates, make sure all of the markup/looks are the same, then add your own stuff in over top.
Hard for me to know exactly what’s going on without seeing full files, but if you duplicate everything and just add on top of it you shouldn’t have any issues.October 1, 2015 at 1:27 pm #141245Andreas
I can send you both files by emailOctober 1, 2015 at 1:27 pm #141247TomLead DeveloperLead DeveloperOctober 1, 2015 at 1:35 pm #141251AndreasOctober 1, 2015 at 2:09 pm #141255TomLead DeveloperLead Developer
So I’m not seeing this line anywhere in there:
<?php do_action( 'generate_before_content'); ?>
If you want to use that hook, it needs to appear in your custom file wherever you want the hooked content to show up.October 1, 2015 at 2:38 pm #141264Andreas
When I use <?php do_action( ‘generate_before_content’); ?> instead the Hook is working but I have a problem with view.
Normally, the first image should not be loaded.October 1, 2015 at 10:49 pm #141336TomLead DeveloperLead Developer
I’m not sure what you mean by that? Is the page header/featured image being displayed? If so, you should be able to hide it with some CSS quite easily.
Let me know 🙂
- You must be logged in to reply to this topic.