[Resolved] Remove thumbnails and infinite scroll from home page only.

Home Forums Support Remove thumbnails and infinite scroll from home page only.

  • This topic has 9 replies, 2 voices, and was last updated 2 months ago by Leo.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1363357
    Virve

    Hi,

    Can you please help me with how I can set the home page (index) of my blog to not show thumbnail and to not use infinite scroll, while keeping thumbnails and infinite scroll in archive, categories, and search results?

    I would like my home page to only show one full article (without thumbnail), but archives, categories, tags and search to show excerpts with thumbnails.

    Thanks!

    #1363477
    Leo
    Staff
    Customer Support

    Hi there,

    Let’s do one step at the time.

    Can you try first adding this PHP snippet?
    https://generatepress.com/forums/topic/limit-the-number-of-post/#post-1311840

    Change 9 to 1.

    Let me know if this solves the infinite scroll issue as well 🙂

    #1365465
    Virve

    Hi Leo,
    Thank you for your fast reply! 🙂

    I inserted the suggested code into functions.php
    However it did not seem to have any effect.

    I just realized I need to change the original plan though, since the footer needs to be accessible on all pages.
    My apologies for the change of plan!

    The new plan:
    1. Show only one full post on the Home Page, while showing 7 excerpts on the other pages (categories, tags, search). (No infinite scroll.)
    2. Remove post thumbnail from the Home Page, while keeping post thumbnails on the other pages.

    This is the current state of my functions.php:

    function generatepress_child_enqueue_scripts() {
    	if ( is_rtl() ) {
    		wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );
    
    add_filter( 'generate_show_excerpt', function( $show ) {
        if ( is_front_page() && is_home() ) {
            $show = false;
        }
    
        return $show;
    } );
    
    add_action( 'pre_get_posts', function( $query ) {
        if ( is_admin() || ! $query->is_main_query() ) {
            return;
        }
    
        if ( is_home() ) {
            $query->set( 'posts_per_page', 1 );
        }
    } );

    Thanks!

    #1366121
    Leo
    Staff
    Customer Support

    Let’s work on one issue at the time.

    Show only one full post on the Home Page

    This is working from what I can see. When I go to the home page, I only see one post titled:
    Mikrokuitusieni poistaa meikin pelkällä vedellä

    Can you confirm?

    Can you also disable the caching plugin while we are working through this?

    #1366575
    Virve

    Yes, that one is fixed. The front page shows only one post. (Problem is still that it also shows the thumbnail picture which I do not want to be shown there.)

    I would, however, need the archive pages and search pages to show multiple posts (7) with excerpts.

    Here’s an example page (category page) that only shows 1 excerpt now:
    https://www.virvefredman.com/kosmetiikka/

    Here’s an example page (tag page) that only shows 1 excerpt now:
    https://www.virvefredman.com/ostolakossa/avainsana/ihonhoito/

    #1366910
    Leo
    Staff
    Customer Support
    #1366964
    Virve

    Thank you!

    I had not yet changed that to 7, since I thought that would also make the home page show 7 posts and I only wanted one post to be shown there.

    Apparently that, however, worked because of some php code that was already there or something. Great that the solution was so easy.

    Now my final issue is the thumbnail picture that is visible on the homepage at the beginning of the post. I want the thumbnails to stay visible on archive pages but not on the home page.

    Any suggestions with this?

    #1367266
    Leo
    Staff
    Customer Support

    Try this CSS:

    .home.blog .post-image {
        display: none;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    #1367602
    Virve

    Perfect, it solved the issue.

    Thank you so much for all your help!

    #1367821
    Leo
    Staff
    Customer Support
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.