Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
3 better title
| link

Set a custom number of Postsposts on the first page on Posts page in WordPress

2 Fixed grammar and code block. Retagged.
source | link

I need to limit the posts shown in wordpressWordPress front page ONon the first page only. The reason for it is a sticky post which breaks my layout and the number of total post set up in default wpWP setting.

I found this function for functions.phpfunctions.php but its apear notit appears to not work. Can

Can you help me to fix it . i? I prefer functions.php changea functions.php change.

I wonder that itsif it's not working because post with this snippet is realyreally new.

add_action( 'pre_get_posts', 'sk_change_posts_per_page' ); /** * Change Posts Per Page for first page of Posts page * * @param object $query data * */ function sk_change_posts_per_page( $query ) {

add_action( 'pre_get_posts', 'sk_change_posts_per_page' );

/**
 * Change Posts Per Page for first page of Posts page
 *
 * @param object $query data
 */
function sk_change_posts_per_page( $query ) {

  if( $query->is_main_query() && ! is_admin() && is_home() && ! is_paged() ) {
    $query->set( 'posts_per_page', '2' );
  }

}

Source http://sridharkatakam.com/set-custom-number-posts-first-page-posts-page-wordpress/Source

I need to limit the posts shown in wordpress front page ON the first page only. The reason for it is a sticky post which breaks my layout and the number of total post set up in default wp setting.

I found this function for functions.php but its apear not to work. Can you help me to fix it . i prefer functions.php change .

I wonder that its not working because post with this snippet is realy new.

add_action( 'pre_get_posts', 'sk_change_posts_per_page' ); /** * Change Posts Per Page for first page of Posts page * * @param object $query data * */ function sk_change_posts_per_page( $query ) {

if( $query->is_main_query() && !is_admin() && is_home() && ! is_paged() ) {
$query->set( 'posts_per_page', '2' );
}

}

Source http://sridharkatakam.com/set-custom-number-posts-first-page-posts-page-wordpress/

I need to limit the posts shown in WordPress front page on the first page only. The reason for it is a sticky post which breaks my layout and the number of total post set up in default WP setting.

I found this function for functions.php but it appears to not work.

Can you help me to fix it? I prefer a functions.php change.

I wonder if it's not working because post with this snippet is really new.

add_action( 'pre_get_posts', 'sk_change_posts_per_page' );

/**
 * Change Posts Per Page for first page of Posts page
 *
 * @param object $query data
 */
function sk_change_posts_per_page( $query ) {

  if( $query->is_main_query() && ! is_admin() && is_home() && ! is_paged() ) {
    $query->set( 'posts_per_page', '2' );
  }

}

Source

1
source | link

Set a custom number of Posts on first page on Posts page in WordPress

I need to limit the posts shown in wordpress front page ON the first page only. The reason for it is a sticky post which breaks my layout and the number of total post set up in default wp setting.

I found this function for functions.php but its apear not to work. Can you help me to fix it . i prefer functions.php change .

I wonder that its not working because post with this snippet is realy new.

add_action( 'pre_get_posts', 'sk_change_posts_per_page' ); /** * Change Posts Per Page for first page of Posts page * * @param object $query data * */ function sk_change_posts_per_page( $query ) {

if( $query->is_main_query() && !is_admin() && is_home() && ! is_paged() ) {
$query->set( 'posts_per_page', '2' );
}

}

Source http://sridharkatakam.com/set-custom-number-posts-first-page-posts-page-wordpress/