Doesn’t the category view do that?
And what d you mean “out of the loop”?
I have a similar related question, on my website I want the standard index page to display posts from only one category. How can I do this? It currently displays all of the categories posts. http://mindset.tk
This might help solve chris’s question as well.
abecks555,
yours is a totally different question.
(First of all stop using that .tk domain – a lot things will not work in WP with that.)
You can use a plugin Plugins.
You can modify The_Loop.
You can use the query_posts tag.
And you can use Google to find more π – see the stickynpost on the main page of the forum: How to search…
Tanks for the reply moshu,
yes category view does that, but I aksed on another thread how I could make category view display as a page with a .php extension and got no reply, so I guess either no-one knows or it’s complicated.
So with some lateral thinking I thought: maybe I can create a page and this page only shows entries from one category, and create another page which only shows entries from another category. But I want them to be pages, something.php.
I thought this could be easy to do, just like I can take stuff out of the sidebar, make it display only certain categories in the cat_list etc and call it sidebar2.php, which I can then include on any other page on my site.
By out of the loop I meant that it does not have to work within the logic of the blog. It should just produce a list of entries of one category, nothing else. Maybe I didn’t express myself properly π
Cheers
Chris
If not in the blog:
– put on the top of your whatever.php file, before everything else, this:
<?php
require('./path-to-your-blog/wp-blog-header.php');
?>
– having that you can use any WP function, including The_Loop in that file
– for excluding categories or to have only one shown… see the links I gave above: Loop, query_posts etc.
Ah, very useful, thank you very much! While you wrote that I found another solution, but it may be somewhat less elegant, I will try both!
What I found was to vcreate a new page called index2.php and put:
<?php
/* Short and sweet */
define(‘WP_USE_THEMES’, false);
require(‘./wp-blog-header.php’);
?>
<?php
if (is_home()) {
query_posts(“cat=3”);
}
?>
…at the top of my page and then use whatever I need of the index page (title, content, comments etc.) below. This would show only items of category 3.
I can then include this page via php include anyweher on my site…
Your solution may be more elegant as I can do without the include an just have the functions referenced driectly!
Thanks for the help, much appreciated!
Chris