• I recently upgraded from b2 to 1.0 so am redoing my index.php. I’m using ‘php the_category’ in my template to display the categories for each post, however it displays it as a link to all posts for that category. I don’t want the link, just the category names as text. I know I had it set up like this in my b2 template but can’t figure out how to do it again. Please help?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Hmm… there’s a tag for the_category_ID so there ought to be one for the_category_name. Try that and let us know whether it works.

    Thread Starter shelleycat

    (@shelleycat)

    There’s no tag the_category_name although it seems that something like that would be useful. Is there any way I can do this without hacking into my files? I’m about 98% sure I didn’t do that last time and it’s always such a pain keeping track of changes ifandwhen I upgrade.
    I’m not sure I understand your reply davidchait. Bits of it yes, but not all of it. I don’t know how to code PHP beyond using these template tags ?? Also, I’m planning on using multiple categories in the future so want it outputting bascially just like it is but without the ugly and unecessary links, so simply echoing the cat name might not work, depending on how multiple categories are handled.

    I don’t understand what WordPress gains through removing functionality that was available with b2.

    Your argument would have been better received (by me at least) without this comment.

    I’m new to WordPress, so I don’t know how the previous versions worked. But I do like having the category made into a link to show all posts posted to that category.
    But I also wish there was a way to have it with, and without, the list tags ‹li›,
    I am currently using it as it’s written for one of my side sections; it’s nice how it is, I’m thinking I’d eventually like to try the dropdown hack, and am wondering if the ‹li›’s will interfere with that.
    Additionally, I’d like to place a PLAIN , (no list tags) “Posted to XXX Category” on the same line as my author/date/comments line that’s under the entry. Since it has the ‹li› tags autogenerated, its dropping down under that line.
    So I put it back under the title…but now it’s picking up my ‹li› styles, and looks strange 8^)
    Is there some code I can add to the template-functions.php that I could have it both ways?
    Thanks,
    Sherri
    https://shreela.f2o.org
    (I’m still struggling with my styles, but only a few things are off at this time)

    woops the (li) tags didnt’ come out right, I’m not used to this forum software, sorry

    Sorry, but in b2 (and in 0.72, for that matter) it was possible to show category names that were neither a link nor a list, so that people had the ability to choose how they wanted the category displayed. That functionality now appears to have been removed, so that it’s now necessary to edit the php files or tinker with the CSS. You might not like me pointing that out (I know the developers are trying to move away from the perception of WordPress as a b2 fork) but I wouldn’t bother giving you feedback if I didn’t care about the success of the project.
    If I get stroppy sometimes (ok, a lot of the time ?? ) it’s because I see a potentially great project being undermined by an occasional disregard of the needs/wants of the average, non-PHP-or-CSS-expert end user, and that frustrates me because I’d like to see WordPress get bigger, not smaller.

    This wasn’t changed because we are trying to move away from b2. As far as I know, we are very proud of our b2 heritage. This was changed because we introduced support for multiple categories.
    Now that we have multiple categories, how would you expect a function like the_category_name() to work if it doesn’t return a list?

    I’m not saying it can’t be done, I am asking you how you’d want it to work. I want you to go through some of the thought process. It’s easy to sit back and criticise, but sometimes the problems are a little more complicated than they appear on first glance.
    We can (and I expect we will) easily add a parameter to the existing function to not have it output the link. The existing function will return an unordered list or a comma separated list.
    Is there another way you want it to work? You want it to output an unordered list if there are muliple categories and just text if there is only one category? Can you see any potential problems with this?
    Here is your chance to design a feature – how should it work?

    Ok, got mine fixed up the way I want it. I copied the_category function, pasted it after itself, named it the_category2, and took out the echo ul stuff, and the li stuff. Then I made the changes to the index, Category: <?php the_category2() ?>
    This unlisted one is still linked, that’s how I wanted it. I’m still using the listed one in my sidebar.
    Thanks

    @shelleycat:
    No problem. If you can add a template-tag, you are writing php code. ??
    (This is OBV a temp solution…) I’ve created a file on my site my-hacks.phps. If you have a my-hacks.php file already, copy the function in my file into yours. Otherwise, copy the file to the root of your blog and rename it to my-hacks.php. Either way, make sure you enable the hacks file in the admin interface.
    This will enable a new ‘tag’: get_category_names(” : “). Its only parameter is the separator between the category names (and it is optional, defaults to comma+space). No ul, just returns a concatenated string of the category names.
    Use it like: <?php echo get_category_names(" * "); ?>
    ——————————-
    @alex – how it might want to work:
    Since I proposed one solution, and I regularly update my functions with extra params/defaults, I’ll take a shot at a possible ‘answer’.
    – a param for links/no-links
    – a param for list/no-list
    >> note that I disagree with making it a list if >1 but not if ==1 — a user should decide if they want it list-styled or not, period.
    – a param for between-multiple-categories separator, used in the no-list case
    defaults might be links=true, list=true, separator=’, ‘
    I wouldn’t mind becoming a ‘cvs-blessed’ contributor at some point, if you all need another set of hands at times. At the same time, I can keep posting away herein… ??
    =d

    David, there is already a param for list/no list and the between multiple category separator. So the only thing you are asking for is what I already proposed – adding a param to turn off the links.

    If it’s already possible to turn off the list using parameters, why hasn’t that been mentioned before?

    That isn’t “turning off the list”, it is showing a list in a different way. I imagine it wasn’t mentioned because the primary request was to “turn off links”.

    That isn’t “turning off the list”, it is showing a list in a different way. I imagine it wasn’t mentioned because the primary request was to “turn off links”.

    My mistake. When you said there was ‘a parameter for list/no list’ that confused me. I assumed that ‘no list’ meant not displaying the links as a list. (I tend to use ‘list’ in its narrowly technical HTML sense; as far as HTML is concerned, if it’s not

      ,

        or <dl> it’s not a list). And there have been more posts about the

          issue than the links, so I was surprised it hadn’t popped up on any of those threads. But then, only a handful of people have access to this kind of information, so maybe I shouldn’t be.
    Thread Starter shelleycat

    (@shelleycat)

    Sorry I was gone so long, real life gets in the way sometimes.
    Thanks for the my-hacks solution davidchait, I’m going to try that as soon as I upgrade to 1.0.1 (which I’m about to do). To me this seems like the obvious way to solve problems such as this, put it in a standalone hack file rather than go into the actual php files and mess with those. This way when I upgrade again (which I’m sure I will) it’s not lost, plus I should be less likely to break other stuff along the way.
    Personally I’d like to see this as an option in the official wordpress relsease. All it needs to do is display all the categories without making them link to anything, I’m happy with the toptions already given for listvs comma deliminated output. However it’s not essential and I’m just as happy adding it into a hack file which can then be included (since I know functionality has been built into wordpress to allow this).
    I’ll report back on how it goes.

    Yeah, definitely drop a line if there’s any problems with it — I can always give you some tweaked code..
    =d

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘how to display post category not as a link’ is closed to new replies.