I am developing my first WordPress theme. I’ve created a custom page for a specific post category, and I would like to display all the posts from this specific category on the page.
The code is largely borrowed from elsewhere, so it’s highly likely that it’s not best practice, but it seems to be working. However, there is one fairly significant problem:
The code I’m using limits the number of posts to the first ten (sorted by alphabetical order). Could anyone tell me how I can change the code I’ve written so that all of the posts in this category will be displayed?
Any help would be very greatly appreciated!
<?php
$r = new WP_Query(
apply_filters(
'widget_posts_args',
array(
'post_status' => 'publish',
'cat' => 5,
'orderby' => 'title',
'order' => 'ASC',
),
$instance
)
);
if ( ! $r->have_posts() ) {
return;
}
?>
<ul>
<?php foreach ( $r->posts as $hof_post ) : ?>
<?php
$post_title = get_the_title( $hof_post->ID );
$title = ( ! empty( $post_title ) ) ? $post_title : __( '(no title)' );
$thumbnail = get_the_post_thumbnail($hof_post->ID);
$excerpt = get_the_excerpt($hof_post->ID);
$aria_current="";
?>
<li>
<a href="<?php the_permalink( $hof_post->ID ); ?>">
<?php echo $thumbnail; ?>
<h3><?php echo $post_title ?></h3>
<p><?php echo $excerpt ?></p>
</a>
</li>
<?php endforeach; ?>
</ul>