Here's the codes i used to display the posts of my custom post "episode"

if( is_home() ){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array('post_type'=>array('episodes',),'paged'=>$paged ) ); }  ?>
<?php  if (have_posts()) : ?>
<?php post_movies_true(); ?>
<?php while (have_posts()) : the_post(); {?>

How can i add post_per_page there to limit the posts of my custom post?

PS: i dont really know how to code im just trying to do some custom modification with the theme i bought. I would really appreciate any help. Thanks.


you can use posts_per_page in the args array to solve your problem.

query_posts( array(
    'post_type' => array( 'episodes', ),
    'posts_per_page' => 5,
) );

Read more on https://developer.wordpress.org/reference/functions/query_posts/


If you don't want to modify template, you can use the action pre_get_posts and modify the posts_per_page parameter.

The code has to be in functions.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.