Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Calling Only Articles from a Specified Category
Hello all!
I’m very, very new to Textpattern, but I have a copy of TP Solutions and I’ve installed 4.0.6 on my server.
I’ve got the style of the site how I like it, but now that I’m trying to fit in the content I’m getting mixed up. On the home page, I’d like to be able to only display articles that have a category of “news”. I haven’t been able to figure it out so far.
Any help would be, well, helpful!
Thanks,
Jordan
Caps lock is cruise control for cool. —Unknown
Offline
#2 2008-04-08 17:07:33
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Calling Only Articles from a Specified Category
To do that you need txp:article_custom instead of txp:article.
But keep in mind that by default category lists and search results also use the front page, and they need a txp:article tag. So you can use conditionals:
<txp:if_search>
<txp:article />
<txp:else />
<txp:if_category>
<txp:article />
<txp:else />
<txp:article_custom category="news" />
</txp:if_category>
</txp:if_search>
or you can have the search and category pages use their own section (ask again if you don’t know how to do that).
Offline
Re: Calling Only Articles from a Specified Category
Thanks very much for your help, Els!
That worked perfectly and gave me a lot of resources to check out.
Thanks again!
Caps lock is cruise control for cool. —Unknown
Offline
Re: Calling Only Articles from a Specified Category
Hi surfwax95,
Glad your site is working…just thought I’d throw in that you could also create a separate section called news, rather than a category. Then use <txp:article_custom section="news" />
to ouput articles from the news section, keeping in mind what Els said. Just another approach.
Offline
Re: Calling Only Articles from a Specified Category
Thanks for posting, nabrown78.
Although it’s only been a few days since I posted that, I’ve already learned so much using the links Els provided (and continuing to read TXP Solutions).
I was having issues understanding the “default” page. My goal was to have all “news” be on the home page and it never occurred to me to make a new section and have it display On Front Page.
So, now I simply have my News section as my homepage, with a simple <txp:article limit=“15 />.
I was over-thinking and now that I’ve got the hang of it I’m finding more to love about TXP.
Thanks again.
Caps lock is cruise control for cool. —Unknown
Offline