Archived topic
{{unknown}} in front of post excerpt
15 replies · Started by Anonymous on February 17, 2015
Not sure what's going on and when this started happening, but in front of some post excerpt on blog page the word {{unknown}} appears.
Tom, can you please check to see if you can help me find a solution?
My blog page is accesible here.
Thanks!
Maybe just to add this:
Those words were not there at the moment the posts were published, they appeared later, but I'm not sure exactly when.
That's weird, never seen that before.
Can you try deactivating all of your plugins and see if it's still there?
Also check the posts themselves and remove it if you can.
I figured it out. In my child theme I have altered the excerpts to show videos that are in the post. I was using this code:
/*
* show video in post excerpt
*/
function custom_wp_trim_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content(''); // Original Content
$text = strip_shortcodes($text); // Minus Shortcodes
$text = apply_filters('the_content', $text); // Filters
$text = str_replace(']]>', ']]>', $text); // Replace
$excerpt_length = apply_filters('excerpt_length', 55); // Length
$excerpt_more = apply_filters('excerpt_more', ' ' . '<a class="readmore" href="'. get_permalink() .'">»</a>');
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
// Use First Video as Excerpt
$postcustom = get_post_custom_keys();
if ($postcustom){
$i = 1;
foreach ($postcustom as $key){
if (strpos($key,'oembed')){
foreach (get_post_custom_values($key) as $video){
if ($i == 1){
$text = $video.$text;
}
$i++;
}
}
}
}
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'custom_wp_trim_excerpt');
When I removed this code, the words {{unknown}} dissapear.
It solved the issue, but now I have to find the other way to show those videos...
Have you tried using the "Video" format? (look for the "Formats" metabox when adding your post).
I have tried, but choosing the video format does nothing, excerpt on the blog page comes out empty. You have to click on the post, to see the video, but I wan't the video to be shown in the excerpt...
Can you give this a try? http://wordpress.stackexchange.com/questions/160735/display-oembed-in-the-excerpt
I have tried these
add_filter('the_excerpt', array($wp_embed, 'autoembed'), 9);
and
global $wp_embed;
add_filter( 'the_excerpt', array( $wp_embed, 'autoembed' ), 9 );
But unfortunately none of them works.
Can you try this one:
add_filter('the_excerpt', array($GLOBALS['wp_embed'], 'autoembed'), 9);
Nope, this one doesn't work either.
I searched the web quite a lot yesterday and tried some other solutions too, but I didn't have any luck...
Interesting - I'll have to look into this further and maybe include it built in with a future update.
For now, try using the embed code provided by YouTube.
Youtube embed code does not work either. As far as I know, wordpress strips all the codes (HTML, shortcodes, multimedia, etc.) in the excerpt and only text is shown.
It would be a great feature to have it built in the theme.
I agree, I'll look into this further :)
Thanks Tom, I must say I admire your outstanding support. Keep up the great work! :)
Just letting you know that in 1.2.9 you can choose the "Video" post format, and it will show full content (so oembed and youtube embeds will show up).
Thanks!