WordPress.org

Ready to get started?Download WordPress

Forums

Link categories the "before" formatting (4 posts)

  1. gyda
    Member
    Posted 7 years ago #

    Hello
    I'm using different classes for lists in the Link Categories, so in the "After" formatting, I left the default, which is </li>. And in the "Before" formatting, I've added different classes, for example: <li class="blogs"> (since I have different list-styles)

    But it's not adding those classes, I check the source and it's always <li> for all the links.

    I didn't edit any php files, so I think it was suppose to work since it's something in the wordpress "cpanel" area.

    I don't know if this is a bug or it's just my files, if anyone could help me.
    Thanks in advance.

    added: I also tried changing themes, default and classic and it's not a problem from there, since it doesn't add the classes either
    might be from links.php in wp-includes folder

  2. gyda
    Member
    Posted 7 years ago #

    This is really troublesome.
    Well, looking in my links.php, in the end is something like this:

    //Display the category name
    echo ' <li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2></li>n";
    // Call get_links() with all the appropriate params
    get_links($cat['link_category'],
    "<li>","</li>","n",
    bool_from_yn($cat['show_images']),
    $orderby,
    bool_from_yn($cat['show_description']),
    bool_from_yn($cat['show_rating']),
    $cat['list_limit'],
    bool_from_yn($cat['show_updated']));
    // Close the last category
    echo "";
    }
    }
    }
    ?>

    in the 6th line, where it's
    "<li>","</li>","n",
    is actually where I wanted the $before.
    I don't know PHP very well, but I understand some logic, the first <li> should have some variable I think.. the one getting the $before, how can I do that?

  3. gyda
    Member
    Posted 7 years ago #

    Well I got help from outside, this $before is only for before the headings in the categories name, I guess. Or is something related, but it's not doing anything anyway that before and after

    Is there anyway to have different classes (for CSS) in the lists (<li>) of each link, inside each category?

  4. ivode
    Member
    Posted 7 years ago #

    Well it hacls the core, but to get the functionality you want (and I wanted) is fairly simple. Change the following 2 lines in links.php.

    Line 552:

    '<li>',"</li>","n",
    to
    $cat['text_before_link'],$cat['text_after_all'],$cat['text_after_link'],

    Line 533:

    sort_desc, list_limit
    to
    sort_desc, list_limit, text_before_link, text_after_link, text_after_all

    Now the before and after tags you put into link categories will show up in the code for each link in that category.

Topic Closed

This topic has been closed to new replies.

About this Topic