[Resolved] Not showing all posts

Home Forums Support [Resolved] Not showing all posts

Home Forums Support Not showing all posts

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1409013
    David

    Hello

    I have this website…

    [In SITE URL]

    Type password: glamping

    I’ve added a custom post type called glamping. I have 14 listings, but only 10 are showing up on the page.

    In Settings > Reading
    I’ve changed… Blog pages show at most to 20.

    Any ideas what is causing the others not to show.

    Thanks
    Dave

    #1409176
    David
    Staff
    Customer Support

    Hi there,

    try including the Post Navigation on the CPT.
    Tom provides a method to do that here:

    https://generatepress.com/forums/topic/displaying-posts-navigation-on-cpts/#post-466321

    #1409182
    David

    Hi David

    If I turn infinite scroll off in blog settings, I get the page navigation back.

    How can I set the number of post to initial show on custom post types, and also use the infinite scroll?

    Thanks
    Dave

    #1409210
    David
    Staff
    Customer Support
    #1409237
    David

    Ok thanks, I’ll look into adding the infinite scroll, only other things is how do I change the option of how many posts show on the archive page?

    #1409294
    David
    Staff
    Customer Support

    You can use the pre_get_posts hook to change the posts_per_page like sp:

    add_action( 'pre_get_posts', function( $query ) {
      if ( is_admin() || ! $query->is_main_query() ) {
          return;
      }
    
      if ( is_post_type_archive( 'my_custom_post_type' ) ) {
          $query->set( 'posts_per_page', 9 );
      }
    } );
    #1409314
    David

    I added this to function.php but nothing changed

    add_action( 'pre_get_posts', function( $query ) {
      if ( is_admin() || ! $query->is_main_query() ) {
          return;
      }
    
      if ( is_post_type_archive( 'glamping' ) ) {
          $query->set( 'posts_per_page', 12 );
      }
    } );
    #1409422
    David
    Staff
    Customer Support

    Odd as thats a standard WP function.
    Have you spoken with the Plugin author? as it seems to be doing things differently.

    #1409481
    David

    Yes all sorted thanks David

    #1409504
    David
    Staff
    Customer Support

    Glad to hear that.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.