I am trying to create a custom loop to display my posts in different styling.
In my posts, I have mostly Youtube videos and some text around. In my posts loop I need to display only thumbnail of the featured image of the posts and the text, but I don't want to display any iframes with my Youtube videos.
I was searching for solutions nad I found this - Display only text to WordPress loop without loosing the text formatting - it should remove iframes and images, which would be great for me, but I have multiple posts loop so I don't really want to affect
the_content() function because it is used in many more different loops in my theme, if you understand my problem. I am not really a programmer so this is tough for me.
edit 1 I have added your code into functions.php but nothing happens. here's my code in template:
<?php global $post; $args = array('orderby' => 'rand', 'posts_per_page' => 1,); $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); ?> <div class="hpvybirame"> <div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1> <?php show_only_thumbnails($content); ?> <?php echo get_the_post_thumbnail($thumbnail->ID, 'vlog-lay-c'); ?> </div> </div> <? endforeach; ?>