WordPress.org

Ready to get started?Download WordPress

Forums

"How To" Present Single Category on Separate Page? (18 posts)

  1. bpolhemus
    Member
    Posted 9 years ago #

    At http://codex.wordpress.org/The_Loop#Exclude_Posts_From_Some_Category,
    there are instructions on how to EXCLUDE a category from display on the main page.

    But what I'd like to know is the COROLLARY to this: How to display that single category exclusively on a DIFFERENT page.

    For instance: Suppose I have five categories, that we'll call #1-#5. Suppose further, that I want to EXCLUDE #3 from the main blog page. That's apparently covered in the Codex entry noted.

    But suppose, still further, that I then WANT to display #3 on a DIFFERENT page altogether.

    How would I do that?

  2. j0llyr0ger
    Member
    Posted 9 years ago #

    Well, I'm no code wizard, but the common sense solution to me seems to be to exclude categories 1,2,4, and 5 from the loop on the category 3 page

  3. bpolhemus
    Member
    Posted 9 years ago #

    I agree, that makes sense, but I'm not enough of a PHP codie to understand how to "and" these together. Any more specific info would be much appreciated.

  4. bpolhemus
    Member
    Posted 9 years ago #

    No further replies?!?!?

  5. One Crayon
    Member
    Posted 9 years ago #

    I would exclude category 3 from the index.php loop, and then link to the category's archive page from somewhere on the main page. You can set up a template page called category-3.php in order to have the category page display the same stuff as the index instead of defaulting to the archive template, as well. That way you don't need to bother with excluding all the other categories, and you get a page for just that category.

  6. bpolhemus
    Member
    Posted 9 years ago #

    Thanks, that makes sense at least in a theoretical way, but of course I'm battling extreme n00bness, here. If I understand you, you're saying "map the ARCHIVES of the category you want to display instead of 'the_posts'" (at least that's what I think I'm reading).

    But can you point me to an example of this?

    Thanks.

  7. iand
    Member
    Posted 9 years ago #

    Two possible solutions (both are on that page, near the bottom):
    1. Use <?php if ( !(in_category('3') && is_home()) ) { ?> as on the codex page. This will hide cat 3 only on the home page. If you then link to cat 3 (instead of cat3.php), only cat 3 will display (using index.php).
    2. Use <?php if ( !(in_category('3')) ) { ?> on index.php and <?php if ( in_category('3')) { ?> on cat3.php.

  8. One Crayon
    Member
    Posted 9 years ago #

    If you don't like IanD's answer, and want to use the category archive:

    - Exclude category 3 from the index: <?php if ( !in_category('3')) { ?>
    - Create a link to category 3 wherever it is that you want the link. One possibility is to use list_cats()
    - Create a template file name category-3.php, and in that file use the same page layout template that you have on your index, minus any main-page specific code (like the excluding if statement)

    If I had my site fully converted to WordPress, I'd toss you a link for an example, but it's not up and running completely yet.

  9. One Crayon
    Member
    Posted 9 years ago #

    Ack, forgot to cose a code tag, sorry about that. I'd edit it if I could.

  10. bpolhemus
    Member
    Posted 9 years ago #

    Okay, we're rolling now. As of now, I have the ability to have any post submitted to that one particular category show up ONLY on the unique page assigned to it, and PERFECTLY in sync with the format on that page. (For reference purposes my "News" page is found at http://www.polhemus.cc/blog/news.php).

    One of the most important things I've discoverd ("DUH!") is that you must have the .php extension on the file. I presume Apache (in my case) has to have this to know to invoke the PHP module. Others can fill us in on that far better than I can.

    Also, I've hacked the "loop" portion of the code so that it shows only the title (with no permalink, since I just want to put my news items up and don't need the "comments" feature).

    What I need to do now (further hacking required) is (1) have it show the posts only from the current month (but ALL those from the current month) on the "live" page but one the option of going back to prior months; (2) an option for "(1)" so that would allow me to have a list of links in the "sidebar" area showing titles of older articles--this option might work with having, say, ten "full" articles in the mainbar and all the others in the sidebar--maybe all the articles YTD.

    Any recommendations along these lines would be very welcome.

  11. Vish
    Member
    Posted 8 years ago #

    bpolhemus

    Wouild you please mind sharing your code snippet on how you got this working?
    Thanks in advance.

  12. Tubaplayer
    Member
    Posted 7 years ago #

    I used this thread to set up a WP site showing only category 1 on front page, and linking to other categories. But now, after upgrading to WP 2.0.3. Anybody know anything about this??

  13. alok_shenoy
    Member
    Posted 7 years ago #

    Can someone exclusively post a howto about this? Since I have no clue about php and coding, the solutions given were simply incomprehensible. Just to make my problem clear : I have a particular category, say, Ramblings, I want that to appear on the main page. I have another category called 'Coding', which I want to be on the 'Coding' page. How do I go about it? Where do I add code and what code do I add? Any help in this matter is duly appriciated and thanked for.

  14. moshu
    Member
    Posted 7 years ago #

    Well, if you couldn't understand from the above and from the links in the Codex - give it up.

    Even writing down once again what was said wouldn't help.

    Just go and use a plugin:
    http://ryowebsite.com/?p=46

  15. alok_shenoy
    Member
    Posted 7 years ago #

    Hey, is there a way where I use the plugin execPHP, Create a new page called Category 1, and write code on that page which calls for the posts in Category1? And remove the Category1 from the category list in the siderbar??

  16. moshu
    Member
    Posted 7 years ago #

    1. The most common misconception. You do NOT need any Page to display posts in a catgeory. You need a Category Template.
    Mandatory reading: http://codex.wordpress.org/Category_Templates
    2. For removing from the sidebar look up the parameters of the template tag used in your sidebar:
    http://codex.wordpress.org/Template_Tags#Category_tags
    (hint: look for "exclude")
    3. Why would you need phpexe? I don't get it.

  17. alok_shenoy
    Member
    Posted 7 years ago #

    Well, I may be frustrating you guys with my throughly noobish questions, please bear with me. You see, I basically got the idea from seeing that when I use a plugin like lazyest gallery, I have to create a page called Gallery and save it with some little snippet of code within the page. But to run the code it is necessary that I have phpexec plugin. That makes the 'Gallery' page appear on top of my header.
    Now with that in mind I thought I want pages for, say, catergory 1 , category 2 etc, which will display sutff which are in the respective category. That said, I got around using 'Faking It' by Chris , which basically is a tutorial to make you wordpress a CMS. But the damn problem is that it works only for 1.2, and not for 2.04. I'm wondering if theres a tutorial like this : http://www.chrisjdavis.org/2004/07/15/faking-it-wordpress-as-cms/1/

  18. moshu
    Member
    Posted 7 years ago #

    There is nothing wrong about being a noob... we all started as a new user at some point :)
    However, it is considered a great sin, if without a thorough understanding of how WP works, you want to force your preconceptions on WP's behaviour. That's the problem: "having ideas" about what should happen - according to you... instead of reading and trying to get around with the built-in solution offered and linked for you.
    (At the time of 1.2 there was no theme system, there were no templates in the theme folder, there wasn't even a theme folder - that's a totally different animal... so why the heck are you looking at everything else except the solution offered?)

    Another common mistake: You "think" you figured out that to achieve goal XYZ - you need a category displayed on a Page. (which is usually a nonsense) It would be much more productive if you describe the desired end result and a knowledgeable helper would give you the solution in a few minutes. Describe your goal, tell us what you want to achieve - and somebody will explain to you how to make it work.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.