Jump to content

Archived

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

Justin Taylor

Why would this custom function NOT work?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Danny

HI,

What is it supposed to do? Can you provide a link to the page it is supposed to be displayed on.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Justin Taylor

Hi Danny

The site is on a test server unfortunately.

The code, hopefully, will add the <div> just prior to the post content. It is part of the code for an AddThis widget. We have other AddThis widgets working so everything else seems to be ok.

We are already adding Google Tag Manager code to the site with the functions.php file successfully too.

Share this post


Link to post
Share on other sites
Danny

Try this:

add_action('pagelines_loop_before_post_content', 'add_addthis_share_code');
function add_addthis_share_code() { ?>
	<div class=\"addthis_sharing_toolbox\"></div>
  <?php
}

 


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Justin Taylor

Thanks for your reply.

Strange one. It's as though the hook isn't there. I'll put it on the back burner until we go live, then I can provide a link for you to look at.

Share this post


Link to post
Share on other sites
Danny

Are you using the WP-Content/PostLoop section ?

If so, try enabling legacy mode.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Justin Taylor

I'm not sure what you mean Danny? I just tried adding a custom function to the child them's functions.php file. It is just this hook that I can't seem to trigger.

I can see the hook being defined in the class.posts.php file, but I can't get any function to fire on it. Seems to get ignored...

Share this post


Link to post
Share on other sites
Danny

The hook you're using is related to the WP-Content/PostLoop section and therefore, if that section isn't active on your page, then no hook will be visible. Therefore, you need the section active on your page.


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?
    • 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
       
    • ketri
      By ketri
      Hi!
      I'm having two problems with my translations. I've shown them in this video:
      https://www.youtube.com/watch?v=Bq2jXeHbd7o
       
      1. When I click edit from any element on page, it's very slow and laggy. If I remove the translations from the themes it then works normally. Why does translation affect this?
      2. My site is using the translation files from the DMS parent theme. The translations in my child theme (western-spirit) only work if I delete the translations from the DMS parent theme. I tried different functions in my child-theme to make it load the translations from there but they didn't work. I tried these:
      function my_child_theme_setup() {load_child_theme_textdomain( 'Western Spirit', get_stylesheet_directory() . '/languages' ); } add_action( 'after_setup_theme', 'my_child_theme_setup' ); and 
      load_theme_textdomain( 'dms', get_stylesheet_directory() . '/languages' ); I also noticed than in these functions for example here http://codex.wordpress.org/Function_Reference/load_child_theme_textdomainthey always have /languges but DMS-theme has /language without the "s".
       
      So I want to edit my site without the weird lagginess that appears when I have translations and I want to use the latest translations from Transifex on my child-theme so my translations won't disappear when I update DMS
       
      Thanks!
    • mundocaco
      By mundocaco+
      Hello, is possible create a function to make a random slide section with RevSlider?
       
      Thank you!
×