Hompage template to show posts only from certain categories

  • Posted in : Read WP
  • KiryGNC
    Participant

    Hello guys,
    Ive bought READ wordpress theme and i installed it on: http://chiriac.info/lista-proiecte/
    I would like that page to use the “homepage template” format and style, but to show posts only from certain categories: “Proiecte” and “Proiecte externe”.
    Ive tried several php codes, but cant keep the format of the page.

    Could you guys help me with the proper php code?

    Thankx in advance.

    KiryGNC
    Participant

    Anyone have any idea?

    Mehmet S.
    Keymaster

    Hi,

    – go to: Appearance > Editor > page-home.php,

    – find:

    $args_homepage = array( 'post_type' => 'post', 'posts_per_page' => -1 );
    

    – edit: Add category_name. Use category slug (NOT name).

    Show Posts for One Category

    – Display posts that have this category (and any children of that category), using category slug:

    $args_homepage = array( 'post_type' => 'post', 'category_name' => 'staff', 'posts_per_page' => -1 );
    

    Show Posts From Several Categories

    – Display posts that have these categories, using category slug:

    $args_homepage = array( 'post_type' => 'post', 'category_name' => 'staff,news', 'posts_per_page' => -1 );
    

    – Display posts that have “all” of these categories:

    $args_homepage = array( 'post_type' => 'post', 'category_name' => 'staff+news', 'posts_per_page' => -1 );
    

    Thanks

    KiryGNC
    Participant

    Thank you very much, works great. ;)

    Mehmet S.
    Keymaster

    You are welcome.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register