Adding new function in functions.php is not loading the page

I need to show the recent blog post on the custom page on website. I am trying to do this without using plugin.

I found this solution but when I add the piece of code in functions.php as suggested by the tutorial, it is not loading the entire website. It throws error as follows

This page isn’t working
www.test.com is currently unable to handle this request.
HTTP ERROR 500

Here is the code I am trying to add in functions.php

<?php
function getFeaturePosts(){
?>
<ul class=”related-posts”>
<?php
$default_thumbnail = ‘https://img.techbrij.com/techbrij%20logo.gif’;
$the_query = new WP_Query(‘showposts=5&orderby=rand&category_name=featuredcategory’);
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<li>
<div class=”related_thumbnail”>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”>
<?php
if (has_post_thumbnail()):
the_post_thumbnail();
else:
?>
<img src=”<?php echo $default_thumbnail; ?>” alt=”<?php the_title(); ?>” />
<?php endif; ?>
</a>
</div>
<div style=”clear:both;”></div>
<div class=”related_permalink”>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></a>
</div>

</li>

<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
<?php
}
?>

Thanks in advance!

Read more here:: Adding new function in functions.php is not loading the page

Leave a Reply

Your email address will not be published. Required fields are marked *