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"); ?>
  • Appreciate it intended for one’s great placing! When i severely relished examining the item, you could end up an incredible article author. I will be guaranteed to help search for your site in addition to will definitely go back fastly. I have to really encourage you go on ones good do the job, employ a pleasant a . m .!

  • Hello,

    I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I’m quite sure I’ll learn a lot of new stuff right here! Good luck for the next! 

  • cari3tech

    Hey,

    its quite tricky. A easy way to fool someone. Awesome Man..... I liked it. Will do it on my blog.

    If you have any such customizations, please share.

    Regards

    Prep
    Station

     

  • Thanks for the tips I will followed them now. recently created my new technical blog. Thanks for explaining step by step process.

  • Thanks for one’s marvelous posting! I seriously enjoyed reading it, you can be a great author.I will be sure to bookmark your blog and definitely will come back very soon. I want to encourage that you continue your great work, have a nice morning!

  • thank you for the supplied  index.php, it is showing only one post of each selected category!!

  • Hello, dear Author!
    If I include your code into my index.php I get an error due to some errors in your function. I am not really good in php, but could you take a look please?

  • i want photo & clip

  • Hi JW, I use this script but I have a problem. When I select the categories it only shows the title and the name of the category, but the text of the lastest news of every one of the category do not correspond to this category.

  • I am trying to use this code on a page. It shows the list of posts as expected, but also the posts content at the bottom of the page which I do not want. I am not sure why this is happening. any Ideas?

    Thank you for a great tip and your site is awesome.

  • Use this code before

  • 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