You can make your own function to minimize the characters typed for each time you want to repeat the call to get_posts
:
in functions.php
(perhaps):
function print_piwa($postcount=2, $cat_id=81) {
?>
<div class="wiadPodtyt">
<ul>
<?php
$piwa = get_posts(array(
'posts_per_page' => $postcount,
'cat' => $cat_id,
'post__not_in' => $news_ids,
'offset' => 1
));
foreach ($piwa as $post) {
setup_postdata($post);
?>
<li>
<a href="https://wordpress.stackexchange.com/questions/73204/<?php the_permalink(); ?>" class="subtytulyWiad">
<?php the_title(); ?>
</a>
</li>
<?php
}
?>
</ul>
</div>
<?php
}
You’ll obviously need to figure out what variables you want to set and use them accordingly, but there’s no reason you can’t use get_posts
in a function of your own making.
Then you can just call your function in your templates:
<?php print_piwa(5, 81); ?>