Using %postname% variable in Twitter shortcode

pending (4 posts) (2 voices)

  1. I'm using the Twitter shortcode (and others) at the bottom of posts. I'd like to wake a widget of that text (for Twitter, Facebook, and Google+) so I can add it to every post easily. Basically trying to create a "social" widget for every post.

    I'd like the prefilled Twitter text to use the %postname% variable in addition to some other text.

    Is there a way to allow the variable name? I tried, but of course it just outputs "%postname%" and not the value of the variable.

    If I can figure it out, I'd gladly post the widget code for all to use.

    Posted 9 months ago #
  2. Elliott
    Support

    Hello rerockstar,

    I'm sorry but I am not sure I understand correctly. If possible then send us a link to your page so we can get a better idea of what your trying to do.

    Posted 9 months ago #
  3. Elliott,

    Here's an example:
    http://www.rebarcampsa.com/2011/08/rebarcamp-san-antonio-beginnings/

    At the end of the post I have used shortcodes to generate the Facebook, Twitter, and Google+ links.

    For each post, this means three shortcodes to generate that group of sharing icons/links. I'd like to create a widget that holds all three of those, so that I can use a widget shortcode to insert that into each post.

    Here's the current shortcodes:
    [fblike layout="standard" show_faces="false" action="recommend" colorscheme="light"]
    [tweet username="REbarcampSA" layout="horizontal" text="How REbarcamp San Antonio came to be. #REBCSA"][googleplusone size="small"]

    In addition, when you click on the Tweet link, it generates a pre-filled tweet with pre-defined information (that I supply in the shortcode with the "text" option). In the case of this post it's "How REbarcamp San Antonio came to be. #REBCSA"

    I'd like to be able to generate the text option using Wordpress' %postname% variable or another variable (I'm not sure what the variable is for titles, but that would be the best one).

    By doing this, I could create a widget that would place all three social icons/links at the bottom of the page, plus pull the post title from Wordpress and place that in the text option.

    Does that make a bit more sense?

    Posted 9 months ago #
  4. Elliott
    Support

    Let's try this,

    Open up /wp-content/themes/awake/framework.php and at the very bottom you should see this,

    ?>

    Before that line add this,

    add_action( 'mysite_singular-post_after_post', 'mysite_custom_social' );
    function mysite_custom_social()
    {
    	echo do_shortcode('[fblike]');
    	echo do_shortcode('[tweet]');
    	echo do_shortcode('[googleplusone]');
    }

    You'll need to edit the shortcodes seen above with your own options and it might display weird so let us know when your done and we'll take a look.

    Posted 9 months ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme