Support » Themes and Templates » [ Theme: Simple Catch ] Need help how showing only one category on the home page

  • Hi i’m using the Simple Catch theme. By default this theme showing all categories on the home page. But i want only one category of post to be displayed on the home page. Can you help me, please… (I am sorry to be poor at English. Thank you.) 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Try it with this in your theme’s functions.php:

    function my_home_query( $query ) {
      // not an admin page and is the main query
      if (!is_admin() && $query->is_main_query()){
    
        if(is_home()){
          // show only category id 22 posts on the home page
          $query->set('cat', 22);
        }
      }
    
    }
    add_action( 'pre_get_posts', 'my_home_query' );

    And change $query->set('cat', 22); to the correct category ID you want to show on the home page.

    @keesiemeijer: thank you, bro … it’s work 😀

    Can u tell me which file should i edit.
    I am not getting it.
    I added the above code and my server went out.

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Can u tell me which file should i edit.

    your theme’s functions.php.

    I added the above code and my server went out.

    Where did you put it?

    at the end just above the closin of php

    in the funcitons.php

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Can you paste and submit the full code of your functions.php into a pastebin.com and post the link to it here? see the Forum Rules for posting code and using the pastebin.

    Hi Ronak,

    It should be working fine and thank Kessiemeijer for answering this question.

    Yes, past your code and if still problem then email us by filling in the contact form in http://catchthemes.com

    Regards,
    Sakin

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[ Theme: Simple Catch ] Need help how showing only one category on the home page’ is closed to new replies.