Wordpress

I wanted to just show my ‘website news’ category in the root of my Wordpress installation. But by default index.php shows the latest posts from all categories, this was not what I wanted. So how could I get what I want?

Step 1

I take a look in index.php. It displays:

<?php /* Short and sweet */ define("WP_USE_THEMES", true); require("./wp-blog-header.php"); ?>

Step 2

After looking at this code I could see, clearly, there was no statement to restrict what category to show, which was what I wanted. So I checked in the Administration>Categories section in the Administration part of my site to find out the category ID of the category I wanted to just show on my index.php in my Wordpress installation root, the category ID was ‘2?. I changed index.php to the following and uploaded it to my webserver:

<?php $blog = 1; if (!isset($cat)) { $cat = "2"; } /* Don't remove this line. */ define("WP_USE_THEMES", true); require("./wp-blog-header.php"); ?>
  • ISHAN SHARMA
    Best Tips to Secure Wordpress Blog/Site here http://how-what.blogspot.com/2...
  • Use this code before

    if (have_posts()) :
    while (have_posts()) : the_post(); .....................


    Change to your category name[you wish to have] instead of "YourCategoryName"
    It works :)
  • Vinit
    also > "4" is the amount of post u wish to do so
  • RaiulBaztepo
    Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I'v just started to learn this language ;)
    See you!
    Your, Raiul Baztepo
blog comments powered by Disqus