0

My problem is that my tweets from Wordpress are truncated and ended with three dots in Twitter. I use "Twitter Auto Publish" plugin on my website. I have also changed recently my Wordpress theme :). I added also the following code to functions.php file in my Wordpress theme:

function my_twitter_cards() {
    if (is_singular()) {
        global $post;
    $twitter_user = str_replace('@', 'ConsolezonePL', get_the_author_meta('twitter'));
    $twitter_url = get_permalink();
    $twitter_title = get_the_title();
    $twitter_excerpt = get_the_excerpt();
    $twittercard_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
    $twittercard_thumb = $twittercard_image[0];
    if (!$twittercard_thumb) {
        $twittercard_thumb = 'http://www.example.com/default-image.png';
    }
    if ($twitter_user) {
        echo '<meta name="twitter:creator" value="@' . esc_attr($twitter_user) . '" />' . "\n";
    }
    echo '<meta name="twitter:card" value="summary_large_image" />' . "\n";
    echo '<meta name="twitter:url" value="' . esc_url($twitter_url) . '" />' . "\n";
    echo '<meta name="twitter:title" value="' . esc_attr($twitter_title) . '" />' . "\n";
    echo '<meta name="twitter:description" value="' . esc_attr($twitter_excerpt) . '" />' . "\n";
    echo '<meta name="twitter:image" value="' . esc_url($twittercard_thumb) . '" />' . "\n";
    echo '<meta name="twitter:site" value="@ConsolezonePL" />' . "\n";
    echo '<meta name="twitter:truncated" value="false" />' . "\n";
    }
}
add_action('wp_head', 'my_twitter_cards');

But still cuts my tweets from Wordpress. And I don't know why, but Twitter Card Validator displays for me only half of my tweets. Example: enter image description here

My website is consolezone.pl. Please help me :).

Velans
  • 1
  • Does the api have a limit on what you can send at once? you know that twitter has a character limit - how do you split up long messages? – Mozahler Mar 24 '18 at 20:02
  • About char limit, I am almost sure it is because of it. Because my last Wordpress tweet (140 characters) was in July 2017 and changes with a larger character limit (280 characters) appeared officially in August 2017. I just do not know how to adjust it, because I can not find such an option in my plugins and I did not think it would cause me such problems :). Please advice me :). You can explain how split up :)? – Velans Mar 25 '18 at 15:24
  • I can't provide code, since these aren't my languages. The basic idea is to make sure that if the information is too long you need to break it into pieces and send each piece in order (resulting in multiple tweets on the receiving side). This would happen near the beginning of the process. Keep trying along those lines until someone else provides you with more help than I can provide. – Mozahler Mar 25 '18 at 17:02
  • But I don't want multiple tweets on my Twitter profile page :D. I want one tweet = one post from Wordpress :D. And I think you can put here some code :), I will try understand it and maybe help me a little :). – Velans Mar 25 '18 at 17:52
  • OK. I favorited your question and will come back later to check up your progress. I'll jump in if I feel I can help. – Mozahler Mar 25 '18 at 17:57
  • Ok then :). But I don't know if someone else will help me if I wrote the topic yesterday :). But I wait :). I need advice :D. – Velans Mar 25 '18 at 18:25

2 Answers2

0

One possibility, in your code above, the twitter:description is ultimately set by get_the_excerpt(); You could try increasing the excerpt size by adding something like this to functions.php, note 50 is the number of words:

 add_filter( 'excerpt_length', function($length) { return 50; } )

If that works, look here or here for tips on how to get the excerpt to precisely 180 characters. Otherwise, you should visit the development support page of Twitter Auto Publishers looks like this is a requested feature already.

Richard Zack
  • 431
  • 3
  • 12
0

My problem is solved :). I had to manually enter the character limit to 280 in the plugin "Twitter Auto Publish". I've seen this option before but apparently I did not check the result after the changes :). I remembered only after Richard's post :). Thank you Richard and Mozahler for your posts :).

Velans
  • 1