Positioning social buttons

2 Replies ·

  1. Hi,

    Running Hybrid Original, I’m just looking for some advice for something I managed to do a long time ago (with your help): positioning social buttons below the entry (and the byline) on single posts view, home page view and my random page view (a page that display random posts), each time –as specified– after the byline. Back then, I had hard coded the buttons myself. Now, I’m using a plugin. The plugin is providing me with a specific function to call the buttons, something like social_button()

    Back then, I used a custom code like this in my functions.php file:

    add_action( 'hybrid_after_entry', 'my_facebook_link', 11 );
    
    function my_facebook_link() {
    
        if ( is_home() || is_singular( 'post' ) || 1452 === get_queried_object_id() ) {
    
            $social = '<p class="fb-like">';
            $social .= '';
            $social .= '</p>';
    
            echo $social;
        }
    }
    

    Where “1452” is the ID number of my random page. is_home() || is_singular( 'post' ) is obvious enough. I don’t know what the 11 stands for in ( 'hybrid_after_entry', 'my_facebook_link', 11 )

    Now, how can I make the samething work with the plugin function social_button() ?

    Thanks alot, as always.

  2. Justin Tadlock

    Hybrid Original — old school. 🙂

    What you want to do should be possible with something like this:

    add_action( 'hybrid_after_entry', 'my_facebook_link', 11 );
    
    function my_facebook_link() {
    
        if ( is_home() || is_singular( 'post' ) || 1452 === get_queried_object_id() ) {
    
            social_button();
        }
    }
    

    I’m not sure if social_button() echos or returns a value. If the above doesn’t work, try change that line to:

    echo social_button();
    
  3. Philippe

    Superb: I got exactly what I was looking for in less than a minute. social_button() was enough and did the trick.

    I started with Hybrid Original back in 2008. So it’s been a decade now. You were and still very much are ackowledged on my about page, which was actually published on June 5, 2008. So there you go, time flies.