• Resolved NateBalcom

    (@lukeslytalker)


    I’m trying to add this to my single.php template with “the_title” so every time I post this is automatically added to my posts with my title included. I love the plugin and I’d like to add it to all my posts. Any idea on how I would format it?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Ben Meredith

    (@benmeredithgmailcom)

    I got this line of code to work by adding it in the content.php file of my theme. (Twenty Fifteen) on line 32.

    Adding it to single.php might work, too. But your milage may vary. Let me know if this gets you on the right track.

    echo do_shortcode( '[bctt tweet="' . the_title( '', '', false ) . '"]');

    Thread Starter NateBalcom

    (@lukeslytalker)

    I’m using Point. There doesn’t seem to be a config in the root of this theme. I was able to pull results with single.php, but I haven’t been able to get the short code formatted properly to pull the title. I’ll continue to work on it.

    Plugin Author Ben Meredith

    (@benmeredithgmailcom)

    Well, I just noticed that the advice I gave in the last post uses a deprecated hook. the-title() is not the recommended way to go any longer. use get_the_title() instead.

    echo do_shortcode( '[bctt tweet="' . get_the_title() . '"]' );

    As long as you are within the loop, that should work.

    Happy to help point you in the right direction if you need it.

    Ben

    Thread Starter NateBalcom

    (@lukeslytalker)

    I just got a chance to give this a shot and it works like a champ. Now I automatically get a better click to tweet every time I post. AWESOME!

    If anyone’s interested in doing this you need to edit your single.php file. It’s located in the root of your theme folder. I added the following line of code to mine.

    <?php echo do_shortcode( '[bctt tweet="' . get_the_title() . '"]' ); ?>

    Plugin Author Ben Meredith

    (@benmeredithgmailcom)

    Sweet! Glad it worked for you!

    If my plugin (or top-shelf support!) have benefitted you, the best way to say thanks is a donation.

    The second best way is an honest review!

    Have a great day!

    Thread Starter NateBalcom

    (@lukeslytalker)

    Done and done. Just donated. Already gave a great review. Love the plugin. I styled it and added it to the top and bottom of my posts. Check out my last post here for a sample –> http://bit.ly/1TOcK9t Have you considered tying the links to bit.ly? Just curious.

    Plugin Author Ben Meredith

    (@benmeredithgmailcom)

    Thanks so much! Yes, using a third party plugin, you can easily integrate with url shorteners. I wrote a tutorial on that. http://benlikes.us/79 Let me know if anything has changed since I wrote that. It should still be similar, though I have not checked on the bitly plugins since I wrote that.

    I personally use YOURLS, so that I own all my links, instead of bitly.

    Thread Starter NateBalcom

    (@lukeslytalker)

    I’ve never used YOURLS. Does it include click tracking? I’ve been using bit.ly for so long now it’s just habit. Is this your first WP plugin? I’d love to build one someday. By the way I set up that bit.ly tip above. Works like a champ. Thanks again.

    Plugin Author Ben Meredith

    (@benmeredithgmailcom)

    Yeah, YOURLS has some analytics baked in. There’s probably a lot more I could do with it, but i haven’t taken the time. The admin dashboard is great for being able to see how many clicks a link is getting. I just like being able to go and change a link (say if a referral program changes, I can still use the same short link. And I like that I “own” the links, as opposed to bit.ly using my data to make more money from others. 🙂

    This is actually my second plugin, and I have a total of 3 released publicly.

    Thanks again for the kind words and donation!

    And, go build a plugin!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘How do I include this in my "single.php" template?’ is closed to new replies.