Genesis Themes

  • Home
  • Genesis Tutorials
  • WP Tutorial
  • Twenty Fifteen Theme
  • Social Media
  • WP Plugins

Genesis Display Posts from One Category on Home Page

Genesis Display Posts from One Category on Home Page

You can easily display posts from a specific category on home page or blog page of any Genesis child theme with the following simple code snippet.Before adding this code,decide which category posts you really want to display on home page,then find the ID of that category.Some may not want to display all category posts on front page, for them it's  a perfect solution to show posts from one category only.

Here's the code to show posts from one category,it works only in genesis themes.Finally replace ID number of 12 with your category ID.Simply paste the following code snippet to your genesis child theme's functions.php file.

add_action( 'pre_get_posts', 'one_category_home_page' );
/**
* @author Syed Bavajan
* @example http://mygenesisthemes.com/
* @copyright 2015 My Genesis Themes
* @post link http://mygenesisthemes.com/genesis-display-posts-one-category-home-page/
*/
function one_category_home_page( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '12' );
}
}

If you face any difficulty and to get additional help use comment form,i will help you.

Related Posts

  • How to Unregister Layouts in Genesis
  • How to Display Category Description in Genesis Child Theme
  • How to Show Last Updated Date in Genesis Theme
  • Show Related Posts With Thumbnails in Genesis
  • Customize or Remove Genesis Footer Credits
  • How to Remove Post Info in Genesis Theme
  • Change Search Box Text in Genesis
  • Genesis Exclude Posts in Specific Category from Home Page / Blog Page
  • How to Remove Post Meta in Genesis Theme
  • Move Genesis Navigation Menu Above Header

Bluehost and Siteground Coupons for January 2016.

Best Premium WordPress Themes from TemplateMonster
download wordpress themes from MonsterOne

Categories

  • Blog
  • Blogger
  • Genesis Tutorials
  • Social Media
  • Top Websites
  • Twenty Fifteen WordPress Theme
  • WordPress Plugins
  • WordPress Tutorial