- This topic has 13 replies, 2 voices, and was last updated 8 years, 6 months ago by Tom.
-
AuthorPosts
-
September 30, 2015 at 3:09 pm #141050Andreas
Hi Tom,
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 DeveloperWhere’s the before header hook? If you’re just using the built in GP
generate_before_header
hook, it will be included in theget_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 #141139AndreasSorry, the Hook is set in “before content”!
October 1, 2015 at 10:42 am #141186TomLead DeveloperLead DeveloperDoes that hook exist in your custom template?
October 1, 2015 at 11:41 am #141201AndreasThe 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 #141205AndreasHey Tom,
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 #141229AndreasWhen 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 DeveloperThe 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 #141245AndreasI can send you both files by email
October 1, 2015 at 1:27 pm #141247TomLead DeveloperLead DeveloperMight be easier to upload them using http://pastebin.com/.
October 1, 2015 at 1:35 pm #141251AndreasOctober 1, 2015 at 2:09 pm #141255TomLead DeveloperLead DeveloperSo 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 #141264AndreasWhen 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 DeveloperI’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 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.