Usage with do_shortcode()?
-
I’m trying to use the
[tweet]
shortcode in a template file, usingdo_shortcode()
‘. Is that possible? (obviously I can’t get it to work…)What I’m trying to do is:
function saotn_related_posts_after_post( $content ) { $blog_id = get_current_blog_id(); if ( $blog_id == "1" && is_singular( 'post' ) ) { // [..] $content .= do_shortcode('[Tweet ""]'); // [...] } return $content; }
Note: the empty Tweet shortcode comes from my code change and feature request. See my email from Fri, 22 Jul 2016 for the following information – for anyone who wants this as well:
In click-to-tweet-by-todaymade\tm-click-to-tweet.php, add the following
in the function tweet($matches), below theif (!empty($handle)) {
block, around line 229:$text = ($matches[1] == "") ? get_the_title() : $matches[1];
This makes the function:
/** * Replacement of Tweet tags with the correct HTML */ public function tweet($matches) { $handle = get_option('twitter-handle'); if (!empty($handle)) { $handle_code = "&via=".$handle."&related=".$handle; } $text = ($matches[1] == "") ? get_the_title() : $matches[1]; $short = $this->shorten($text, 100); return "<div class='tm-tweet-clear'> [!snip rest of code!] </div>"; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Usage with do_shortcode()?’ is closed to new replies.