• Resolved Guillermo

    (@guillermo77)


    Hi tom, just one question if you or any can help me, I don’t know about wordpress function.

    I want add the code of like facebook button after the post, and if is possible after the plugin “share buttons adder”- (if can also before post)
    For exp:

    function share_this($content){
        if(!is_feed() && !is_home()) {
            $content .= '<div class="share-this">
                        <div class="fb-like" data-layout="button_count" data-action="like" data-size="large" data-show-faces="false" data-share="false"></div>
                    </div>';
        }
        return $content;
    }
    add_action('the_content', 'share_this');

    Because plugins use iframe version no responsive.-

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Guillermo

    (@guillermo77)

    I wanted to say after post and before some plugin like related post, just control the order will appear.
    I like also add the url permalink to data-href=”” because in multisite no get the url.

    Theme Author Tom

    (@edge22)

    Hi there,

    You can try hooking it into the generate_after_entry_content hook.

    Something like:

    function share_this(){
        if(!is_feed() && !is_home()) {
            echo '<div class="share-this">
                        <div class="fb-like" data-layout="button_count" data-action="like" data-size="large" data-show-faces="false" data-share="false"></div>
                    </div>';
        }
    }
    add_action('generate_after_entry_content', 'share_this');
    Thread Starter Guillermo

    (@guillermo77)

    The 2 codes are ok, just is difficult put it in order of display I want. Is one problem of wordpress.
    Is possible display in order modifying the plugins and functions with one number at the end: add_action('generate_after_entry_content', 'share_this',1);

    The only problem is in multisite, facebook take just the website domain.
    I try something how data-href="'. get_permalink(); .'" But give me error.

    Thanks

    Theme Author Tom

    (@edge22)

    Hmm, I’m not sure there’s anything you can do about that.

    You need to remove the ; after get_permalink().

    ; should only be at the end of the line.

    Thread Starter Guillermo

    (@guillermo77)

    This run and maybe can be useful to others. The last number is the order display 1 for put after the post, can be 10 to put it before comments.

    function share_this($content){
        if(!is_feed() && !is_home()) {
            $content .= '<div style="margin-top:1em">
                        <div class="fb-like" data-layout="button_count" data-href="'. get_permalink() .'" data-action="like" data-size="large" data-show-faces="false" data-share="false"></div>
                    </div>';
        }
        return $content;
    }
    add_action('the_content', 'share_this', 1);

    The plugins use the iframe version but not is responsive with 450px width.

    Theme Author Tom

    (@edge22)

    Awesome! ??

    Thanks for sharing your working code.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘About functions after post like button facebook’ is closed to new replies.