WordPress.org

Ready to get started?Download WordPress

Forums

Simple Catch
[resolved] Posts - Limit the number of post only in home page, not in other categories. (7 posts)

  1. AleJjo
    Member
    Posted 1 year ago #

    Hi, i need some help.

    I have the limit of 10 post for every category in my site, and this is like i want it. But i need to show only 3 post in the home page or (index).

    Can someone help me please.

    http://wordpress.org/extend/themes/simple-catch/

  2. Catch Themes
    Member
    Theme Author

    Posted 1 year ago #

    Build a child theme and add the following code in your function.php file:

    /**
     * Fixing the Number of Post
     * Used in Homepage
     */
    function simplecatch_home_custom_query( $query ) {
    
    	if (  is_home() )
    		$query->query_vars['posts_per_page'] = 3; // Change 3 to the number of posts you would like to show
    
    	return $query; // Return our modified query variables
    }
    add_filter( 'pre_get_posts', 'simplecatch_home_custom_query' ); // Hook our custom function onto the request filter

    Regards,
    Sakin

  3. AleJjo
    Member
    Posted 1 year ago #

    Im really happy, it worked perfect! that's exactly what i needed thanks Sakin!

    One more thing, please. I forgot to ask how to take the "previous link" at the bottom only in home page. To show only the 3 post and nothing else.

  4. Catch Themes
    Member
    Theme Author

    Posted 1 year ago #

    You can hide that through custom css. This will be better. Send me your Site URL and then I will send you the CSS.

  5. AleJjo
    Member
    Posted 1 year ago #

    Hi, thanks for your help, im sorry for not writting earlier.

    This is the web page: http://www.goldensunfl.com/web/

    I would like to remove, or hide the previous and next button , only in homepage. I hope you can help me, i tried with css, but couldnt make it.

    Thanks!

  6. Catch Themes
    Member
    Theme Author

    Posted 1 year ago #

    @AleJjo: You can just hide it by adding the following css in "Custom CSS" box at Appearance -> Theme Options -> Custom CSS

    .home .default-wp-page {
        display: none;
    }
  7. AleJjo
    Member
    Posted 1 year ago #

    Thank you!!! :D It's working perfect, just what i needed, thank you very much!!!

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic