How can Recent blog in main page only show posts from one category

edited August 2018 in Busiprof
Hello,

I create two main category: Products and News, so i can add post into both of them.

But in the main page, i only want Recent Blog show posts from News, i don't want it show posts from Products.
How can i make this possible?

Many thanks!

Comments

  • Hi

    Thanks for asking query to us .
    Your query is a part of feature enhancement. However, you can get the result via manually code customization in a file.
    To show specific category post in recent news section . Follow the given below instruction . 
    1 Copy the index-blog.php file located in your theme folder  and past it inside the child theme directory .
    2 Ignore the above step if you already  added the file in child theme directory .
    3 open this file and find the below line of code on line no 25 . 

    $args = array( 'post_type' => 'post','posts_per_page' => 8,'post__not_in'=>get_option("sticky_posts")) ; 

    And replace it with below line of code .

    $args = array( 'post_type' => 'post','posts_per_page' => 8,'post__not_in'=>get_option("sticky_posts"), 'cat' => '28') ; 

    Cat 28  is the category id from which would you want to show post on recent news section .
    Here, '28' is the category ID which we want to show.
    You have to manually put the ID of the category which you want to show.

    Use Reveal IDs plugin to view category ID in Categories section.More help see the snapshot .

    Let me know did it work.

    Thanks
    Akhilesh


Sign In or Register to comment.