Jump to content

Archived

This topic is now archived and is closed to further replies.

ketri

When I add code using the same hook via Hook Editor or functions.php, they end up in different places

Recommended Posts

ketri    7
ketri

When I use the wp_footer -hook to add some code to my page, the code ends up in different place if I use the child-themes functions.php than if I use the Hooks Editor in the WordPress-admin.

When I use the Hooks Editor to add code to wp_footer, it goes to the footer. Nice!

When I use functions.php and write: 


function testfunction1() {
    echo '<!-- the same (?) test used in child-themes functions.php-->';
}
add_action('wp_footer', 'testfunction1', 10);

It doesn't go to the footer. Instead when I look at my source code it's about 1/4 from the top.

Am I using hooks wrong? Shouldn't this have the same result and the code in the wp_footer (before closing </body>  tag)

Thanks!

Share this post


Link to post
Share on other sites
Danny    1,327
Danny

Hi,

 

I have no issue using a hook with wp_footer

 

function testfunction1() {
    echo '<!--Hello World-->';
}
add_action('wp_footer', 'testfunction1', 20);
 

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
ketri    7
ketri

Hmm. I have no idea why it now works when I copy-pasted your code. I disabled/enabled plugins, removed all custom stuff in Hooks Editor etc so maybe something just messed something up
Thanks anyway!

Share this post


Link to post
Share on other sites
Danny    1,327
Danny

No problem.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • Dana
      By Dana+
      Hi DMS team,
      Please help out on how to add Post tags to the bottom of each post. Tried looking at the hooks tutorials but not sure what to do here.
      Thanks a lot.
       
       
       
       
    • jvheintze
      By jvheintze+
      I just tried to figure out how to use Lax in combination with Post Thumbnails the following way: instead of showing the Featured Image on top of the content section I would like to have a Lax section above the content which loads for each post the featured image. To do so it seems there should be some kind of word press hook support necessary (not ready yet)? Or did I miss something?
    • Justin Taylor
      By Justin Taylor
      I am using a child theme (the pl-starter-theme-master) and have added the following custom function to the child functions.php file:
      // Add AddThis share code to blog posts add_action('pagelines_loop_before_post_content', 'add_addthis_share_code'); function add_addthis_share_code() { echo"<div class=\"addthis_sharing_toolbox\"></div> "; } It isn't do anything. Can someone see why?
    • vanessabt
      By vanessabt+
      Hi, 
       
      I am starting to build a new site.  I would really like to use the MasterSlider plugin for my homepage slider.  I loaded it in and when I use it if I paste the generated shortcode into the page as instructed it ends up showing at the bottom of a content loop section instead of  at the top of the page.
       
      I realize that a hook probably needs to be added to tell pagelines to run masterslider,  but for the life of me I have no clue what needs to be put in or where it would go.
       
      I am building a demo site first before the site is moved so that I can troubleshoot issues like this.  I downloaded the base child theme since I figured we would need add the customization there to be safe from updates and for some reason the hooker section does not show up even though the plugin is installed so I cant use that either.
       
      I am also confused. do I use an action hook from pagelines or one from the masterslider site, http://masterslider.com/doc/wp/developer/#action-hooks.
       
      I tried to put both of these into the functions.php document
       
      <?php get_masterslider(1); ?> 
      <?php echo get_masterslider(1); ?>
       
      but all that seem to do was break the site.
       
      Does it need to be something like:
       
      add_action('pagelines_page', 'masterslider_homepage');
         function masterslider_homepage(1) {
         <?php masterslider(1); ?>
      }
       
      I am sure that is probably nothing but a hot looking mess, but I am at a complete loss of ideas with this.  And where does code like this go into the functions php document? I thought it would go at the very top but I sure I am wrong.
       
      Please let me know if you can provide any guidance.
       
      Thank you
       
×