WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Removing Link Attributes for a Category Currently Being Browsed (9 posts)

  1. Jonathan Landrum
    Member
    Posted 8 years ago #

    Hello everyone,

    I would like to know how to remove the link attribute from a category that is currently being browsed. For instance, in my sidebar under the heading "Pages" the current page being viewed is not a link but is regular text. I did this with this script:

    <li><?php if ( is_page('2') ) { ?>About<?php } elseif ( is_404() || is_archive() || is_category() || is_home() || is_page() || is_search() || is_single() ) { ?><a href="/about/" title="About Stuff">About</a><?php } ?></li>

    where page 2 is my About page. How can I achieve this same thing in my categories without manually listing them as I have my pages? By the way, I am manually entering the links to my pages because the wp_list_pages call didn't list the Home page. I guess I'm just weird like that.

    Thanks for your help,
    ~Jonathan

    http://www.jonlandrum.com

  2. Jonathan Landrum
    Member
    Posted 8 years ago #

    Any takers?

  3. Jonathan Landrum
    Member
    Posted 8 years ago #

    What I have with my page nav is this:

    » Home
    » About
    » Archives

    with the above example being what displays when the user is on the home page, obviously. I am wanting a way to do the same thing with my categories. Any ideas?

  4. wairoanz
    Member
    Posted 8 years ago #

    I'd be interested in this too Jon.

  5. Jonathan Landrum
    Member
    Posted 8 years ago #

    What I am looking for is an "if" statement that will say something like if is $cat then display "» $cat" elseif display "» link to $cat".

  6. Jonathan Landrum
    Member
    Posted 8 years ago #

    Here's what I've come up with so far, but there are errors. Anyone care to help me out?

    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=1'); { ?><?php } if ($this->is_category = true); { ?><?php } echo ('$cat'); { ?><?php } elseif ($this->is_category = false); { ?><?php } the_category(', '); ?><?php } ?>

  7. Jonathan Landrum
    Member
    Posted 8 years ago #

    I thought that maybe I could put the whole thing into one call like this:

    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchial=1'); AND foreach if ( is_category ($current_category) ) ( (get_the_category() ) = $cat ) return $cat; elseif ( is_404() || is_archive() || is_category() || is_home() || is_page() || is_search() || is_single() ) return (this is where it really gets confusing; any ideas?)

  8. Jonathan Landrum
    Member
    Posted 8 years ago #

    I did figure out that I don't have to have the elseif statement, but can rather put else. So the new page links are formatted as:

    <li><?php if ( is_page('2') ) { ?>About<?php } else { ?><a href="/about/" title="About Stuff">About</a><?php } ?></li>

    I think I'm getting closer to the answer, but I fear the answer might lie in the wp-includes folder. I certainly hope not.

  9. Jonathan Landrum
    Member
    Posted 8 years ago #

    Well, I think I have decided to manually link to my categories. Besides ending this brain-wrenching ordeal, I also would like a little more control over how the categories are displayed. On the screen they look fine, but the HTML code it makes is kind of crappy looking. I know, I'm ├╝ber anal about stuff like this, but I want all my line breaks and tabs to line up, and I don't really want to go into wp-includes to adjust how wp_list_cats displays the links. Plus, by manually linking I can decide which categories show and which ones don't, and I'll be able to apply the famous link-removing trick to them with ease! Thanks anyway for thinking about it with me.

    ~Jonathan

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.