I'm trying to print just the first line of content on wordpress post:
$lines=the_content();
$lines=explode("\n", $string);
echo $lines['0'];
But it doesn't work. I must say I have looked everywhere, even trying with this and this. But nothing works... what can I do? Thanks in advance.
EDIT: I add this for you to understand better what I want to do. I want to print different content depending of the publishing date of the post. So, I have more than 300 posts that have a link of youtube/vimeo in the first line that converts into an iframe when it is printed. So i need that the first line of the content gets printed, because the rest is given by the different snippets: titulo, duracion, sinopsis, etc...
$pdate = strtotime(get_the_date("d/m/y"));
$mydate = strtotime('09/10/2019');
if ($pdate < $mydate)
{
echo ONLY FIRST LINE OF CONTENT;
echo '<br/>';
echo '<strong>Título:</strong> ';
echo ''.the_title().'.<br/>';
echo '<strong>Duración:</strong> '.get_post_meta(get_the_ID(), 'time_duration', TRUE).'';
echo '<br/>';
echo '<strong>Sinopsis:</strong> ';
echo get_the_excerpt();
echo '<br/>';
echo '<strong>Director/@s:</strong> ';
echo get_the_term_list( $post->ID, 'director', '', ', ', '');
echo '.<br/>';
echo '<strong>Género:</strong> ';
echo get_the_term_list( $post->ID, 'genero', '', ', ', '');
echo '.<br/>';
echo '<strong>Año de producción:</strong> ';
echo get_the_term_list( $post->ID, 'any');
echo '.<br/>';
echo '<strong>Recomendación por edades:</strong> ';
$category = get_the_category();
$first_category = $category[0];
echo sprintf( '<a href="%s">%s</a>', get_category_link( $first_category ), $first_category->name );
echo '.<br/>';
echo '<strong>País/es:</strong> ';
echo get_the_term_list( $post->ID, 'pais');
echo '.<br/>';
echo '<strong>Idioma:</strong> ';
echo get_the_term_list( $post->ID, 'idioma');
echo '.<br/>';
echo '<strong>Información adicional:</strong> '.get_post_meta(get_the_ID(), 'informacionadicional', TRUE).'';
echo '<br/>';
echo '<br/>';
}
else {
echo '<br/>';
echo $td_mod_single->get_content();
echo '<strong>Título:</strong> ';
echo ''.the_title().'.<br/>';
echo '<strong>Duración:</strong> '.get_post_meta(get_the_ID(), 'time_duration', TRUE).'';
echo '<br/>';
echo '<strong>Sinopsis:</strong> ';
echo get_the_excerpt();
echo '<br/>';
echo '<strong>Director/@s:</strong> ';
echo get_the_term_list( $post->ID, 'director', '', ', ', '');
echo '.<br/>';
echo '<strong>Género:</strong> ';
echo get_the_term_list( $post->ID, 'genero', '', ', ', '');
echo '.<br/>';
echo '<strong>Año de producción:</strong> ';
echo get_the_term_list( $post->ID, 'any');
echo '.<br/>';
echo '<strong>Recomendación por edades:</strong> ';
$category = get_the_category();
$first_category = $category[0];
echo sprintf( '<a href="%s">%s</a>', get_category_link( $first_category ), $first_category->name );
echo '.<br/>';
echo '<strong>País/es:</strong> ';
echo get_the_term_list( $post->ID, 'pais');
echo '.<br/>';
echo '<strong>Idioma:</strong> ';
echo get_the_term_list( $post->ID, 'idioma');
echo '.<br/>';
echo '<strong>Información adicional:</strong> '.get_post_meta(get_the_ID(), 'informacionadicional', TRUE).'';
echo '<br/>';
echo '<br/>';
}