List of posts for a specific category

If you want to display a list of posts, including the thumbnail, there may be a conflict as I experienced, so instead of like  “Notice: Trying to get property ‘ID’ of non-object in /wp-includes/post-thumbnail-template.php on line 101″. The reason is often caused by the existence of a particular plugin.

In these circumstances, you can create your own page where you can enter the code:

$ctg_art = get_posts('cat=80&numberposts=5');
foreach ($ctg_art as $post): setup_postdata($post);
<table style="margin:0;padding:0px;">
<td style="width:90px; vertical-align: top;margin:0;padding:0">
<a href="<?php the_permalink() ?>" ><?php the_post_thumbnail('thumbnail'); ?></a>
<td style="vertical-align: top;margin:0;padding:0px">
<span class="" >
<?php the_time( get_option( 'date_format' ) ); ?> <i class="fa fa-arrow-circle-down"></i>
<a href="<?php the_permalink() ?>" ><?php the_title(); ?></a>
<?php endforeach;?>

Obviously the value of expression cat=80 can be set for the target category. Also, if instead of numberposts=5 (as in the picture) is chosen, for example, the value of -1 instead of five articles will show all posts. In the shown example, I intend to create a table of posts, with the first column containing the thumbnail, and publication date and title will be displayed in the second column. Obviously, if we wanted to, we could also invoke the excerpt.

Author: Ovidiu.S

I am quite passionate about this professional area as if I know something - no matter how little - I want to share it with others.

Leave a Reply