Support » Fixing WordPress » Code From Months Ago Stopped Working

  • I was running this code on my site a few months ago, and I’m nearly certain it was functioning properly (I started to switch to pre_get_posts, not sure 100% sure I finished this bit). Either way, I believe the code below used to work, and now it doesn’t. Everything here is entirely ignored, why is that?

    `function change_posts_per_page( $query ) {
    if ( $query->is_main_query() && $query->is_home() ) {

    $args = array(
    ‘category_name’ => ‘featured’,
    ‘posts_per_page’ => 2, //4 posts are being displayed, it used to show 2 with this code.
    $query->set( ‘args’, $args );

    return $query;
    add_action(‘pre_get_posts’, ‘change_posts_per_page’, 1);

  • The topic ‘Code From Months Ago Stopped Working’ is closed to new replies.