Genesis Themes

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

Show one category Posts on Home Page in WordPress 2015 theme

Display Posts from a Specific Category on WordPress page

WordPress Twenty Fifteen Theme Tutorial to Show only one Category posts on home page and blog page.This code works in all WordPress themes.

Display posts from one category on page of your WordPress website is a really great idea.I implemented this code in one of my WordPress website (top engineering colleges) to show latest posts only from USA schools category.

Here's a code snippet to display only one category posts on a page.Paste the following code in your WordPress twenty fifteen child theme's functions.php file and replace the category ID number with your own category ID.This code will display one category posts in your WordPress blog/home page.

//category on home page

add_action( 'pre_get_posts', 'one_category_home_page' );
function one_category_home_page( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'cat', '6' );
    }
}

Don't forget to replace category ID number 6 in the above code with your category ID, which you want to show all posts from that category only.

Related Posts

  • Exclude Category Posts from Homepage in WordPress
  • How to Avoid CSS @Import in any WordPress Child Theme
  • How to Remove Elegant Themes Footer Links
  • How to Add Logo to Twenty Fourteen Theme
  • How to Add Expires Headers in WordPress
  • Recommended WordPress Ping List 2017
  • Top 10 Most Popular Google Adsense Alternatives 2016
  • Best Settings for Async JS and CSS WordPress Plugin
  • Inline Small CSS To Speed Up Your Website
  • How to Combine External CSS Files in WordPress

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