Forums

Displaying categories on pages and more (6 posts)

  1. rockn4him
    Member
    Posted 3 years ago #

    So, I am heading up an educational resources website and as part of this we would like to display cases to go thru for learning.

    What we are trying to do is:

    Say I have the category CASE. By default if you display this category the topic of the post(in our case, the name of the diagnosis) is displayed. This is fine, but I was wondering if I can some how use page templates (or something else, can't do it with cat templates) to make 1 link to display the category w/out the title (to work as an unknown diagnosis case list), and another link to display the same category with the title (so if ppl just want to browse around)?

    Additionally is there a way to have a hyperlink to a page that contains posts from multiple categories.

    Thanks.

  2. stvwlf
    Member
    Posted 3 years ago #

    Hi

    I do not understand what you mean by

    to make 1 link to display the category w/out the title (to work as an unknown diagnosis case list), and another link to display the same category with the title

    Additionally is there a way to have a hyperlink to a page that contains posts from multiple categories.

    yes

    your details are too sketchy to give specific examples. feel free to expand on them

  3. rockn4him
    Member
    Posted 3 years ago #

    Okay I'll try:

    Say I have posts from category X. When I click on that category, the normal structure of displaying a post is, post title, then post contents, next post etc... So I'd like to also have a link which displays the same category X, without the post title. So it'd just be, post contents, next post etc... In summary what I need is 2 links, each to the same category, but displayed in a slightly different way.

    The second question is: Can I display 2 (or more) categories post simultaneously? Example: Say I want to display only the posts from cats 1, 4, and 30. How would I make a page or create a url to do that?

    hope this helps.

  4. stvwlf
    Member
    Posted 3 years ago #

    Hi

    Question #1 - I still don't understand. When you are saying "two links" - are these on the same page right next to each other, on a different page altogether?

    Can you make an image, a diagram, an example of what you are looking for, perhaps as a jpg file, put it up on a website and link back to it here so I can see a visual of what you are after? Mainly I don't understand the relationship between the two links - part of the same block of display? on another part of the page? A picture will be worth a thousand words...

    Not displaying the title is simple - you just remove the line of code that displays the title and leave the rest of the code.

    ================================
    Question 2: to display only certain categories on a page:

    as example, the name of the page is "Special Categories"
    Create a static page in WordPress called "Special Categories" with a page slug of special-categories - that would be the default page slug for that page name

    Open up your page template file
    /wp-content/themes/{themename}/page.php

    find the start of the WordPress loop
    ( more or less like this- sometimes one line)

    <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>

    paste in this code BEFORE those two lines

    <?php
    if (is_page('special-categories') {
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("cat=1,4,30&amp;paged=$paged");
    }
    ?>

    Now you have created a page that will displaying only posts from those 3 categories when the page being displayed is Special Categories

  5. stvwlf
    Member
    Posted 3 years ago #

    the forum software changes an ampersand to & in the above code, change & to a single ampersand

  6. rockn4him
    Member
    Posted 3 years ago #

    Yeah, I'll make a diagram for you this weekend. I'm on call tonight so I won't be able to get to it. Thanks for your help so far.

Topic Closed

This topic has been closed to new replies.

About this Topic